Retrieve data about lookup properties – Using Web API

While querying data using Dynamics CRM 2016 Web API you may require to get the additional information associated with lookup field in the selected entity (Right now only ID of the lookup record will return in response). Although calling Web API is very straight forward in Dynamics CRM 2016 but to retrieve the data associated with Lookup field you would need to pass the additional headers with every API request.

Overview of this scenario is explained here – Retrieve data about lookup properties

In this blog I am going to demonstrate with you the request creation for this type of API call, before that let’s look at the output of the request to opportunities entity where Account & Contact are the lookup fields

Request – https://*****.api.crm8.dynamics.com/api/data/v8.0/opportunities

To save the time I have used the postman app inside chrome browser.

1

JSON response contains “_parentaccountid_value” which is record id of the associated account.

Now call the same request with following additional headers,

3

And observe the response with addition information about Contact & Account  lookup field, the response contains additional attribute of lookup logical name and formatted value.

2

Let’s call the same API request from java script web resource with the help of XMLHttpRequest() object, You can refer following piece of code

4

Advertisements

3 thoughts on “Retrieve data about lookup properties – Using Web API

  1. Krish June 15, 2016 / 10:07 am

    But, does it support on mobile client as well? I believe not, pls suggest how to implement this to be Mobile supportive…

    Thanks in advance..

    Like

    • Pramod Dhokane June 15, 2016 / 11:05 am

      I don’t think it will support , Actually I had business requirement where I need to pull up this information on custom web resource and anyways mobile client has no full support for custom web resource.
      Or else if you can manage it through custom java script code then probably it will work.

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s