Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Answered

using FetchXML to get the values of Global Choices dropdown fields

Posted on by 35

Hi,

I'm using SSRS for creating reports but missing how you pull the data from Choice lookups.

For example I have this field  <attribute name="cr4fe_servicepaymentterms" />  in my fetchxml, but it is just returning the ID, not the text of the lookup.

thanks

  • Hitesh Nagpal Profile Picture
    Hitesh Nagpal 5 on at
    RE: using FetchXML to get the values of Global Choices dropdown fields

    Hello, I was also stucked in this common problem, I was using dataverse, for me what worked is below syntax while displaying the values

    for choice field - logicalname.label (here using .value will give you id of the choice)

    for lookup field - logicalname.name ( in my case I needed name, you can try other column here)

    Thanks,

    Hitesh

  • dvcooper Profile Picture
    dvcooper 35 on at
    RE: using FetchXML to get the values of Global Choices dropdown fields

    Thanks Pablo,

    This answered my question in a round about way : )

    I'm using XrmToolbox to build my query string, however, what I noticed is that the results in XrmToolbox give me the quid value not the lookup value. so when i do this query in toolbox:

    <fetch>
    <entity name="opportunity" >
    <attribute name="ownerid" />
    <attribute name="owneridname" />
    <attribute name="cr4fe_koboldservice" />
    </entity>
    </fetch>

    I only get these results

    pastedimage1612105568809v1.png

    But when I run the same query in visual studio, I get both the guid and the lookup text as expected. 

    Thanks again for your response.

  • Verified answer
    PabloCRP Profile Picture
    PabloCRP 1,086 on at
    RE: using FetchXML to get the values of Global Choices dropdown fields

    Hi dvcooper,

    Indeed when you retrieve a lookup value with FetchXml you'll get a GUID value.

    Making a link entity and get the name will work.

    But as you are using SSRS notice that 3 field are adding to your DataSet. So pick just cr4fe_servicepaymentterms

    cr4fe_servicepaymentterms LOOKUP's TEXT e.g: FOO
    cr4fe_servicepaymenttermsValue LOOKUP's GUID e.g: 319e2387-38b1-4200-91bb-3bb5410a4a3a
    cr4fe_servicepaymenttermsEntityName LOOKUP's EntityName e.g: cr4fe_servicepaymentterms
    please consider marking as an answer if it was helpful
  • Suggested answer
    prt33k Profile Picture
    prt33k 6,907 on at
    RE: using FetchXML to get the values of Global Choices dropdown fields

    Hi David,

    You will not get the name field directly in fetchxml.

    You need to outer join the link entity and select the primary attribute from this entity.

    You can go to advanced find and then select the column you want into display column and then download the fetch..

    An example to show accountnumber from contact having account lookup as company name:

    pastedimage1612053457411v1.png

    <link-entity name="account" from="accountid" to="parentcustomerid" visible="false" link-type="outer" alias="a_c">
    <attribute name="accountnumber"/>

    Thanks,

    Prateek

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,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans