Sunday, April 17, 2022

Power Automate: How to get the value of a lookup column in Create HTML Table action

In the below table, I wanted to show the name of the Owner. But if you add the Owner (Value) column directly using dynamic content, you know that it shows the GUID instead of the name. So here is what you need to do.

HTML Output using Power Automate

You need to enter the content as an expression and append the value @OData.Community.Display.V1.FormattedValue after the column name. Here is how the expression will look (without the " quotes) "item()?['_ownerid_value@OData.Community.Display.V1.FormattedValue']", and the value is going to look like a function as shown below.

Create HTML Table action step in Power Automate

So, the question is how do you build this expression for the Owner column or any other field (column) in Dynamics 365 CE (Customer Engagement)?

  • Let the Owner (Value) Dynamic content be selected.
  • Click the 3 dots next to Create HTML Table.
  • Select Peek Code.
  • You'll see the value as item()?['_<FieldName>_value']
Note: The <FieldName> may be any lookup field name too.

Lookup value using Power Automate
  • Copy this value in a notepad.
  • Append the value as mentioned above so the whole value looks item()?['_<FieldName>_value@OData.Community.Display.V1.FormattedValue']
  • Copy this in the Expression section and click OK.
Note: This works if the you're using a Dataverse connector. It doesn't work if your connector is Dynamics 365 connector. This happened to me. I was using the List records (Dynamics 365) connector and how much ever I tried the above expression, it still would show the GUID. I then changed the connector to Dataverse and used the List rows (Dataverse) action step instead to fetch the records, and the same expression worked.

Until next time!

No comments:

Post a Comment