web
You’re offline. This is a read only version of the page.
close
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,
I have the same question (0)
  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    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.

  • winston he Profile Picture
    220 on at

    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
    DarrenMog Profile Picture
    50 on at

    Thanks Andrew

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Service | Customer Service, Contact Center, Field Service, Guides

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 57 Super User 2025 Season 2

#2
Daniyal Khaleel Profile Picture

Daniyal Khaleel 34 Most Valuable Professional

#3
Scott Jackson UK Profile Picture

Scott Jackson UK 22

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans