Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Answered

Get EntityReference fields from Opportunity entity using OData

(0) ShareShare
ReportReport
Posted on by 10

I was given a Fetch XML and used it lik so: /api/data/v9.0/opportunities?$count=true&fetchXml=%3.........

the results gave me just the IDs of the related names I expected, not the names.

It C# and  Microsoft.PowerPlatform.Dataverse.Client.Dynamics I get the names just by adding them to  q.ColumnSet = new ColumnSet({here}

and the result is of type "EntityReference" but I need this query for JavaScript.

When I add the referenced to the $select=, i get error that they do not exist . also when I use them in &expand=   

Is there a syntax I am missing to do this in REST?

Thank you

  • Guido Preite Profile Picture
    54,082 Moderator on at
    RE: Get EntityReference fields from Opportunity entity using OData

    with my tool you can fetch the relationships, under Table there are the relationships (one-to-many, many-to-one, many-to-many) press select and find the relationship and the columns you want to fetch

  • OferGal Profile Picture
    10 on at
    RE: Get EntityReference fields from Opportunity entity using OData

    This ownsome. thank you man!

    I was able to get all the formatted values.

    The only item I can't figure out is in a one to one relation.

    In C# I get it with 

     q.LinkEntities.Add(new LinkEntity("opportunity", "ecg_org", "ecg_practice", "ecg_orgid", JoinOperator.Inner));
     q.LinkEntities[0].Columns.AddColumns("ecg_division");
     q.LinkEntities[0].EntityAlias = "Practice";

    The XML has

          
    

    I use React fetch so I need to npm Xrm.Utility.? 

    until now I just got a token and put it in the header.

    Thanks again

  • Verified answer
    Guido Preite Profile Picture
    54,082 Moderator on at
    RE: Get EntityReference fields from Opportunity entity using OData

    the OData syntax of lookups is different (they don't use the logical name) use my tool Dataverse REST Builder to build the query and generate the JavaScript code to read the result.

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

News and Announcements

Now Available: 2025 Release Wave 2

Quick Links

Ramesh Kumar – Community Spotlight

We are honored to recognize Ramesh Kumar as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Adis Profile Picture

Adis 136 Super User 2025 Season 1

#2
Sohail Ahmed Profile Picture

Sohail Ahmed 81

#3
Jonas "Jones" Melgaard Profile Picture

Jonas "Jones" Melgaard 77 Super User 2025 Season 1

Product updates

Dynamics 365 release plans