Given several Users, how to find a team that ONLY contains those users?
-
16. května 2012 7:55
Hi,
Now, assume I have user A, B and C.
I want to find out a Team, ONLY has A, B and C in it.
Something like
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">
<entity name="teammembership">
<attribute name="systemuserid" />
<attribute name="teamid" />
<filter type="and">
<condition attribute="systemuserid" operator="in">
<value>A's Guid</value>
<value>B's Guid</value>
<value>C's Guid</value></condition>
</filter>
</entity>
</fetch>But this will give all teams has A, B and C in it.
Thanks for any help
- Upravený UoAXiayu 16. května 2012 7:57
Všechny reakce
-
16. května 2012 9:51
Hi,
use following fetchXML
<?xml version="1.0"?>
<fetch distinct="true" mapping="logical" output-format="xml-platform" version="1.0">
<entity name="team">
<attribute name="name"/>
<attribute name="teamid"/>
<order descending="false" attribute="name"/>
<link-entity name="teammembership" intersect="true" visible="false" to="teamid" from="teamid">
<link-entity name="systemuser" to="systemuserid" from="systemuserid" alias="aa">
<filter type="and">
<condition attribute="systemuserid" value="A's Guid">
<condition attribute="systemuserid" value="B's Guid">
<condition attribute="systemuserid" value="C's Guid">
</filter>
</link-entity>
</link-entity>
</entity>
</fetch> -
16. května 2012 10:32Moderátor
I don't think you can do this with one FetchXml query. I think you'd need a second query, and then you'd need some external logic to compare the results of the 2 queries. Your second query could either:
- Return a count of the team members, and if it's more than the number of users tested, then discard the team
- Return teams that contain a user who is not one of A, B or C. Any matching teams should be discarded
Microsoft CRM MVP - http://mscrmuk.blogspot.com http://www.excitation.co.uk
- Upravený DavidJennawayMVP, Moderator 16. května 2012 10:32
- Označen jako odpověď UoAXiayu 22. května 2012 2:02
-
20. května 2012 21:37
Hi _Vikram,
Your way does not work...
The result will be empty if I use 2 conditions
<condition attribute='systemuserid' operator='eq' value='A's Guid'/>
<condition attribute='systemuserid' operator='eq' value='B's Guid'/>
-
22. května 2012 2:05
Return a count of the team members,
discard team whose member <> 3
Compare these 3 member teams' id with ids in 1st query result.
Is this what you mean?