RE: lookup field how to list key and value from Dynamics web API
Hi,
Thank you for your query.
Lookups are references to an entity (N:1 relationship).
There is no specific end-point that provides a list of lookup as key-value pairs. You need to point to entity dataset name to get the list.
For example, we have 3 lookups on an entity:
- Account
- Primary Contact
- Category (custom entity)
To get these you have the following approaches:
- Get the list of Accounts/Contacts with only the ID/Name attribute and convert this to a list of a key-value pair in your code. To get this data, just use endpoint with lookup dataset name, for example:
- dynamics.com/api/data/v9.0/accounts$select=name
- dynamics.com/api/data/v9.0/contacts$select=name
- dynamics.com/api/data/v9.0/new_categories$select=name
- You can also use expand to get the data from the lookup entity (along with the current record):
Getting Lookup Fields from Dynamics 365 Web API URL - Carl de Souza