Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Saved Query Not Returning All Columns via Web API

Posted on by Microsoft Employee

Forgive me if this has been covered somewhere already; a cursory search says it hasn't, but I may have missed it. I have a user query (a saved Advanced Find) that I'd like to retrieve via the Web API, ultimately using the data in Power BI. However, the fields returned when I either execute the Fetch XML (via FetchXML Builder) or via sending a get request via the browser, I get different results than when I run the Advanced Find via the UI, namely, that columns are missing from the results of the two former methods. Any ideas? Below you will find the FetchXML of the query, relevant screenshots, and the JSON returned by the query. 

The FetchXML:

<fetch version="1.0" top="10" >
  <entity name="opportunity" >
    <attribute name="elcn_academicprogramofinterestid" />
    <attribute name="createdon" />
    <attribute name="opportunityid" />
    <attribute name="parentcontactid" />
    <order attribute="elcn_academicprogramofinterestid" descending="true" />
    <link-entity name="contact" from="contactid" to="parentcontactid" alias="a_4e29b74a612a43f0969e0b8e08ce7e48" >
      <attribute name="regent_firstcontactdate" />
      <attribute name="createdon" />
      <attribute name="regent_contactstatus" />
      <attribute name="datatel_prospectsourceid" />
      <attribute name="regent_leadsourcedetails" />
      <attribute name="regent_leadsource" />
      <filter type="and" >
        <condition attribute="createdon" operator="this-fiscal-year" />
        <condition attribute="customertypecode" operator="eq" value="200000" />
        <condition attribute="statecode" operator="eq" value="0" />
      </filter>
    </link-entity>
  </entity>
</fetch>

The JSON returned by navigating to .../api/data/v8.0/opportunities?userQuery=8f518d26-db4a-e711-80c1-e0071bf8e783 (GUID of Advanced Find)

{
  "@odata.context": "https://###.###.###/CRMRECRUIT/api/data/v8.0/$metadata#opportunities(createdon,_parentcontactid_value,_elcn_academicprogramofinterestid_value,opportunityid)",
  "value": [
    {
      "@odata.etag": "W/\"270469221\"",
      "createdon": "2017-03-02T17:30:37Z",
      "_parentcontactid_value": "6df9e349-3960-404b-af80-03d096a942fe",
      "_elcn_academicprogramofinterestid_value": "367f7329-fbf1-e511-80c4-0050569b65f8",
      "opportunityid": "1c983ded-6dff-e611-80cd-e0071bf2c07b",
      "a_4e29b74a612a43f0969e0b8e08ce7e48_x002e_createdon": "2017-03-02T17:30:29Z",
      "a_4e29b74a612a43f0969e0b8e08ce7e48_x002e_regent_firstcontactdate": "2017-03-02T17:30:38Z",
      "a_4e29b74a612a43f0969e0b8e08ce7e48_x002e_regent_contactstatus": 653410002,
      "a_4e29b74a612a43f0969e0b8e08ce7e48_x002e_datatel_prospectsourceid": "947c3a05-77d3-e611-80c0-e0071bf8e783"
    },
... Etc...

The results from FetchXMLBuilder

 FetchBuilder.png

Notice for the last two that  regent_leadsource and regent_leadsourcedetails are missing as columns.

Any help would be greatly appreciated.

Thanks, and God bless,

Daniel Hines

Regent University

Christian Leadership to Change the World

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Saved Query Not Returning All Columns via Web API

    Thank you all, that was my issue.

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Saved Query Not Returning All Columns via Web API

    It is by default, fields with empty value will not be shown in the result.

  • Verified answer
    ashlega Profile Picture
    ashlega 34,475 on at
    RE: Saved Query Not Returning All Columns via Web API

    Hi,

     not sure about FetchXmlBuilder, but, for the webAPI.. If you look at the same opportunity (1c983ded-6dff-e611-80cd-e0071bf2c07b) in the Advanced Find, will you see any value in the regent_leadsource column?

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!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans