The trick to get developers to get your job done for free is to challenge them. Which is exactly what Steve “Mr SMB” Mordue has done.
Challenge
I am trying to create a view of activities, that will show all activities performed by anyone on my team. I know I can create specific view that filters that way, but I don’t want to create one for each of the 9 teams. I want to recognize the team I am on and show it.
Accepted
A bunch of linked entities later, Andrii “Granny’s Moonshine” Butenko had a solution:
And that would have been the end of it but then the discussion went something like this:
– I need me, my team, and all members of that team
– So records can belong to Team as well?
– Yes
– Aah, crap
So the challenge now was to combine the expression above with the condition “Owner Equals Current User’s Team” using OR operator. Except that visual view builder would have none of it. At some point Jonas “FXB” Rapp was summoned and solved the problem between brushing his incisors and molars. Readers digest:
- Build a view with the columns that you need and the condition above.
- Fire up XrmToolBox, load that view into View Designer then start editing query in FetchXML Builder.
- Mix conditions on attributes from different entities in the builder.
- Test your fetchxml then update your view.
- Done! (Note: the view will work but you won’t be able to edit that view in Advanced Find).
Winning FetchXML:
<fetch mapping="logical" output-format="xml-platform" version="1.0" distinct="true" > <entity name="activitypointer" > <attribute name="activitytypecode" /> <attribute name="subject" /> <attribute name="statecode" /> <attribute name="prioritycode" /> <attribute name="modifiedon" /> <attribute name="activityid" /> <attribute name="instancetypecode" /> <attribute name="community" /> <attribute name="ownerid" /> <attribute name="owneridname" /> <filter type="or" > <condition attribute="ownerid" operator="eq-useroruserteams" /> <condition attribute="systemuserid" entityname="tm" operator="eq-useroruserteams" /> </filter> <link-entity name="systemuser" to="owninguser" from="systemuserid" link-type="outer" > <link-entity name="teammembership" to="systemuserid" from="systemuserid" link-type="outer" > <link-entity name="team" to="teamid" from="teamid" link-type="outer" > <link-entity name="teammembership" to="teamid" from="teamid" alias="tm" link-type="outer" /> </link-entity> </link-entity> </link-entity> </entity> </fetch>
I was dead last in this contest – my own version wouldn’t even work. As it turns out, link-type="outer"
is important, don’t leave home without it.
(Cover photo by Bernard Tuck on Unsplash)
[…] Tip #1211: Mixing entities to build complex views […]