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 :
Customer experience | Sales, Customer Insights,...
Answered

How can I retrieve all sales team users linked to an opportunity?

(1) ShareShare
ReportReport
Posted on by 20

Hey all,

I'm new to using dynamics and need to query a specific opportunity entity by Id and get an array of all users included in its sales team. I'm trying to use the method of retrieving related entity records described in this documentation:

https://docs.microsoft.com/en-us/powerapps/developer/common-data-service/webapi/retrieve-related-entities-query#retrieve-related-entities-by-expanding-both-single-valued-and-collection-valued-navigation-properties

The issue is that the link between an opportunity and a team member has to go through an intermediate team entity. I am trying to query opportunity entity => opportunity_Teams => teammembership_association => fullname (of team member). Am I going about this double expansion in an advisable way?

An attempted query:

opportunities?$select=opportunityid,name,_parentaccountid_value&$filter=opportunityid eq 'some-opp-id'&$top=10&$expand=opportunity_Teams($expand=teammembership_association($select=fullname))

This query isn't returning anything for the team members in teammembership_association array even though the opportunity I am requesting has a member in the UI. Is opportunity_teams the correct field to be looking for that team member link? Is there something else I'm doing wrong?

Greatly appreciate any advice.

Opportunity entity documentation I've been following:

https://docs.microsoft.com/en-us/dynamics365/customer-engagement/web-api/opportunity?view=dynamics-ce-odata-9

I have the same question (0)
  • BobbyDev Profile Picture
    20 on at

    Hey all,

    I'm new to using dynamics and need to query a specific opportunity entity by Id and an array of all users included in its sales team. I'm trying to use the method of retrieving related entity records described in this documentation:

    https://docs.microsoft.com/en-us/powerapps/developer/common-data-service/webapi/retrieve-related-entities-query#retrieve-related-entities-by-expanding-both-single-valued-and-collection-valued-navigation-properties

    The issue is that the link between an opportunity and a team member has to go through an intermediate team entity. I am trying to query opportunity entity => opportunity_Teams => teammembership_association => fullname (of team member). I'm I going about this double expansion in an advisable way?

    An attempted query:

    opportunities?$select=opportunityid,name,_parentaccountid_value&$filter=opportunityid eq 'some-opp-id'&$top=10&$expand=opportunity_Teams($expand=teammembership_association($select=fullname))

    This query isn't returning anything for the team members in teammembership_association array even the opportunity I am requesting has a member. Is opportunity_teams the correct place to be looking for that team member link? Is there something else I'm doing wrong?

    Great appreciate any advice.

    Opportunity entity documentation I've been following:

    https://docs.microsoft.com/en-us/dynamics365/customer-engagement/web-api/opportunity?view=dynamics-ce-odata-9

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    I'm afraid double expand approach doesn't work.

    You should check how to run queries using FetchXml - docs.microsoft.com/.../retrieve-and-execute-predefined-queries

    This way you will be able to get data from 3-rd level deep.

  • Verified answer
    Johao Larios Profile Picture
    1,795 on at

    Hello there,

    I suggest you create a view in the UI, then download the fetch of that view an try the fetchXML webapi function:

    docs.microsoft.com/.../retrieve-and-execute-predefined-queries

  • BobbyDev Profile Picture
    20 on at

    Thanks for letting me know!

  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    If replies helped you take a minute and click "Yes" under the question "Did this answer your question?" at the top of the reply helped you.

  • Elijah Stownton Profile Picture
    192 on at

    Hi BobbyDev,

    Try to use the following query: skyvia.com/.../top-opportunities

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 > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 83 Super User 2025 Season 2

#2
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 49 Most Valuable Professional

#3
#ManoVerse Profile Picture

#ManoVerse 40

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans