locked
Not able to fetch “Name” of lookup fields of Link-Entity (Web API + FetchXml) RRS feed

  • Question

  • I have some fetchXml that I am executing through the Dynamics CRM Web API. THe fetchXml query is constructed like so:

    <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
      <entity name="new_someEntityA">
        <attribute name="new_lookupForSomeEntityA" />
      <link-entity alias="new_someEntityB" name="new_someEntityB" from="entityBId" to="entityAId" visible="false" link-type="outer">
        <attribute name="new_lookupForSomeEntityB" />
      </link-entity>
      </entity>
    </fetch>
    

    When I send this query through the Web API, I get a response and the value for "new_lookupForSomeEntityA" includes the value (GUID) and a Formatted Value (it's name). But the response for "new_lookupForSomeEntityB" includes just the GUID and I can't find a way to get it's GUID and value. I've added a header record for:

    "Prefer": "odata.include-annotations=OData.Community.Display.V1.FormattedValue"
    

    but that appears to just get me formatted values for the primary entity and not the link entity. Is this a limitation of the Web API or am I doing something wrong? Any help would be appreciated.

    Also asked here: http://stackoverflow.com/questions/41028451/not-able-to-fetch-name-of-lookup-fields-of-link-entity-web-api-fetchxml

    Thursday, December 8, 2016 12:15 AM

All replies

  • Is this a 1:N relationship from A -> B ?  So A would be like the account entity, and B would be like Contact?
    Thursday, December 8, 2016 1:07 PM
  • It's a N:1 relationship from A -> B.
    Thursday, December 8, 2016 2:45 PM
  • You need to use alias with the attribute which you want to retrieve from linked entity.
    https://community.dynamics.com/crm/b/crminogic/archive/2014/04/03/use-of-alias-in-fetchxml


    Regards Faisal

    Tuesday, December 13, 2016 9:47 AM