Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Query to See Users that are NOT members of a particular team

(0) ShareShare
ReportReport
Posted on by 496

I've read several pages of search results on this but haven't quite found the answer.

  • I have a team that will contain all US Citizens called "The ITAR Team".
  • I have a View where I have queried the User table for my custom field holding the citizenship (export clearance)
  • Initially when I set the system up, I bulk-added all the people on that view to the team.  That worked out great.
  • However now, let us say I want to add any newly added US Citizens to a team, I cannot so easily do so.  What I have found is that if you select all from a view, and the system runs into a team member already on the team, it will stop adding. 

So now I have a need to build a View of Users where user.citizenship = "US" and user is _not_ member of US Team.    I have tried doing this with the "Teams" related entity...  Teams.Team Does Not Equal "US Team".  However, that doesn't seem to work - I can clearly see members of the team listed on the results.  I have tried a few other variations too.  It seems like if the user is a member of at least one team other than the mentioned team, it returns true.  Is there a better way to do this?

Here is my FetchXml for the failing query, in case it makes sense to you.

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">
  <entity name="systemuser">
    <attribute name="fullname" />
    <order attribute="fullname" descending="false" />
    <filter type="and">
      <condition attribute="new_exportclearance" operator="eq" value="100000001" />
    </filter>
    <link-entity name="teammembership" from="systemuserid" to="systemuserid" visible="false" intersect="true">
      <link-entity name="team" from="teamid" to="teamid" alias="ai">
        <filter type="and">
          <condition attribute="teamid" operator="ne" uiname="ITAR Team" uitype="team" value="{CF0A1BE6-2279-E611-8100-0050569F5CD5}" />
        </filter>
      </link-entity>
    </link-entity>
  </entity>
</fetch>

*This post is locked for comments

  • Suggested answer
    Aiden Kaskela Profile Picture
    Aiden Kaskela 19,692 on at
    RE: Query to See Users that are NOT members of a particular team

    Hi,

    Queries like this are a real weakness in CRM's interface, but there's a solution. Using FetchXML, you can do a left outer join on your link so you can get all records that don't have {this relationship}. Here are the details on that: msdn.microsoft.com/.../dn531006.aspx

    If you want to do that natively in the Advanced Find window, you can install Intelligent Query from the CRM app source or www.cobalt.net/cobaltintelligentquery . It's really easy to use.

    Hope this helps! I'd appreciate if you'd mark this as Answering your question.

    Thanks,

     Aiden

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans