How to get entitysetname while setting lookup value in Power Automate

If you have worked with DataVerse and Power Automate, chances are likely that you have created a record in DataVerse using Power Automate. And when you create a record, there are times when you need to need to set a lookup field on the record.

This post is specially relevant if you are trying to set a lookup value with data from previous step.

Let’s take an example. In the below Power Automate flow, I create a contact whenever an account record in created in DataVerse.

How to get entitysetname while setting lookup value in Power Automate

Check how we are setting the Company name field which is a lookup to the account table. We are using the entitysetname of account which is the accounts and then passing the GUID of the account from earlier step. While it may seem like to be true, entitysetname is not plural name.

Let’s take even more complex scenario. The scenario with polymorphic lookups.

Observe how I am setting the Owner field with the owner of the account. No problem with that. Afterall, we are just setting the lookup value.

However the issue here is while setting the lookup value, you need to provide entitysetname of the lookup table just like while setting company name field. Observe I am using systemusers.

Sometimes this entitysetname is really tricky and not to forget you need to hardcode the same. More so in case of Polymorphic lookups like Owner, where the owner can be a user or team, things are even more complicated. Well no more

With Power Automate, we now get an additional property for a lookup field apart from the regular Type and Value field. Let’s see what’s that. Below is the screenshot for the Owner field of the account in the Dynamic content selector.

How to get entitysetname while setting lookup value in Power Automate

Observe the first suggestion in the Dynamic content. There is another property for lookup fields in Power Automate apart from the regular Type and Value. And that is Table Name.

I select that and now my formula looks like below

How to get entitysetname while setting lookup value in Power Automate

Let’s execute the flow and examine the input parameters for Create contact step.

How to get entitysetname while setting lookup value in Power Automate

Wonderful isn’t it. No more hardcoding. No more checking the Type for polymorphic lookups.

Hope this helped!

You will also like the below posts.

Debajit Dutta
Business Solutions MVP