Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Service | Customer Service, Contact Center, Fie...
Suggested answer

Xrm.WebApi.retrieveMultipleRecords using teammembership_association every team being returned.

(0) ShareShare
ReportReport
Posted on by 50

Hi all,

I'm new to dynamics and this is my first go at using JavaScript with Xrm.WebApi class.

I'm trying to find if a user is within a team.

I grab the user ID

var UserId = Xrm.Page.context.getUserId();
UserID = UserId.slice(1,-1); //Remove the brackets either end
then run the command below:
Xrm.WebApi.retrieveMultipleRecords("team", "?$select=name&$expand=teammembership_association($filter=systemuserid eq (" + UserID + "))").then(
Every time i run the query, it returns every team in the system and the user is only a member of three teams.
i've tried removing the brackets from the filter section but same results apply.
Any help on this matter, would be great.
Cheers,
  • Suggested answer
    DarrenMog Profile Picture
    50 on at
    RE: Xrm.WebApi.retrieveMultipleRecords using teammembership_association every team being returned.

    Thanks Andrew

  • winston he Profile Picture
    220 on at
    RE: Xrm.WebApi.retrieveMultipleRecords using teammembership_association every team being returned.

    Hi Darren

    1. User and Teams is kind of N:N relationship , which means : A user can belongs to multiple teams , and a team can have multiple users as well. That explains why 3 teams returned when you query a single user ID.

    2. If you want to check if one specific user belongs to a specific team, you need to apply extra filter saying teamid eq <team GUID>.

    Here is the web API you can get all users&teams records:

    https://<yourdomain>.crm*.dynamics.com/api/data/v9.0/teammemberships

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: Xrm.WebApi.retrieveMultipleRecords using teammembership_association every team being returned.

    Hello,

    I would recommend to use retrieveRecord of systemuser entity based on UserID with expansion on teammembership.

    Also you can use FetchXml approach instead approach you used.

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,137 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,879 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans