Getting Lookup Fields from Dynamics 365 Web API URL

1 Comment

In Dynamics 365, we can use the Web API to return records through a web browser URL. In this post, we will look at how to get the lookup field data.

Let’s use Accounts as an example. We can access the API through the address https://yourorg.api.crm.dynamics.com/api/data/v9.1/:

We can then get accounts using https://yourorg.api.crm.dynamics.com/api/data/v9.1/accounts:

Now, accounts have a lookup field for Currency:

We can select the currency field through the Web API using https://yourorg.api.crm.dynamics.com/api/data/v9.1/accounts?$select=_transactioncurrencyid_value. However, this will only give us the Id of the Currency, not the name (e.g. US Dollar) or other fields:

To do this, we need to know the field details for the Transaction Currency field. Go to the field in Customizations. We can see the name transactioncurrencyid:

We can use https://yourorg.api.crm.dynamics.com/api/data/v9.1/accounts?$select=_transactioncurrencyid_value&$expand=transactioncurrencyid:

We can see this returns many fields for the transaction currency id. We can further filter this by https://yourorg.api.crm.dynamics.com/api/data/v9.1/accounts?$select=_transactioncurrencyid_value&$expand=transactioncurrencyid($select=currencyname):

Note if this doesn’t work and you get the message “cannot find a property named …”, try using the schema name, e.g. TransactionCurrencyId.

Carl de Souza
Keep learning. Keep building.

Explore AI, agents & Microsoft technology.

I share practical ideas, tutorials, and videos about AI, AI agents, Microsoft technologies, and the Power Platform.

Subscribe on YouTube →
Carl de Souza Enterprise Architect at Microsoft · AI Technology Expert

One Response to Getting Lookup Fields from Dynamics 365 Web API URL

  1. This is very useful, thanks.

    Is it possible to filter by fields of Currency? for example, contains(currencyname, ‘dollar’)

Leave a Reply

Your email address will not be published. Required fields are marked *