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.

THANKS FOR READING. BEFORE YOU LEAVE, I NEED YOUR HELP.
 

I AM SPENDING MORE TIME THESE DAYS CREATING YOUTUBE VIDEOS TO HELP PEOPLE LEARN THE MICROSOFT POWER PLATFORM.

IF YOU WOULD LIKE TO SEE HOW I BUILD APPS, OR FIND SOMETHING USEFUL READING MY BLOG, I WOULD REALLY APPRECIATE YOU SUBSCRIBING TO MY YOUTUBE CHANNEL.

THANK YOU, AND LET'S KEEP LEARNING TOGETHER.

CARL

https://www.youtube.com/carldesouza

 

ABOUT CARL DE SOUZA

Carl de Souza is a developer and architect focusing on Microsoft Dynamics 365, Power BI, Azure, and AI.

carldesouza.comLinkedIn Twitter | YouTube

 

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 *