I got a challenge from my colleague at CRMK:
I need to set owners on accounts with a team with the same name as the account.
Mia @ CRMK
Is that even possible??
Yes, it actually is.
Simplest query
I start with a very simple query to get all Accounts:
<fetch>
<entity name='account'>
<attribute name='name' />
<attribute name='ownerid' />
</entity>
</fetch>
New supported link-entity feature
I need to join with Teams, not by a relationship like OwnerId, but by their only Name.
<fetch>
<entity name='account'>
<attribute name='name' />
<attribute name='ownerid' />
<link-entity name='team' from='name' to='name'>
<attribute name='name' />
<attribute name='teamid' />
</link-entity>
</entity>
</fetch>
Are those from
and to
attributes on the link-entity
node supported?? Well, oh yes! Do read! No relationships
Unexpected new filtering feature
Also, I don’t want to return accounts that already have the correct owner, so I add a filter by a really new cool feature…
<fetch>
<entity name='account'>
<attribute name='name' />
<attribute name='ownerid' />
<filter>
<condition attribute='ownerid' operator='ne' valueof='T.teamid' />
</filter>
<link-entity name='team' from='name' to='name' alias='T'>
<attribute name='name' />
<attribute name='teamid' />
</link-entity>
</entity>
</fetch>
I thought I just found this unsupported feature when I was testing/trying a few months ago… But in the newly released documentation, it just is there! Read about this doc too: Cross table comparisons
Bulk Data Updater
How to set those owners? Use a tool… 🤓
Bulk Data Updater for XrmToolBox.
User the query above and set this attribute (column) to be updated:
The key is to Calculate, and find the id with team:{T.teamid}
.
It’s not a big thing, but it’s a huge solution for the requirement. Mia IS happy now!
FetchXML Builder
You should know, though – you can create those things that are not yet supported in FetchXML Builder by using the Fetch XML View:
Joining with non-relationships can be done by un-clicking Show only Lookups/IDs attributes in the link-entity node.
Soon supporting
This tool is trying to be on the edge and supports everything the platform can handle.
My free time is limited currently, but as you know, I promise this tool will improve even further by supporting these new features in Fetch XML!