top of page
  • Writer's pictureMatthias Schmitz

How to get the option set label with Power Automate?

Updated: May 7, 2023

In many projects I have seen people stumble about this topic. Especially the ones that started to build their first apps with Dataverse as a datasource instead of using their previous SharePoint lists. Therefore, I would like to show you to today how you get the label of an option set and use it to write an e-mail as an example.


First, we will have a look how we would handle this situation with SharePoint.

Second, I am going to show you how you can achieve the same functionality with Dataverse.

For this example we will check open orders and order with the status "In progress" on a daily base and send an e-mail to customer service to take care of this.


In SharePoint our list may look like this and we can see clearly the three values for the Order status choice column "Done","In progress" and "Open".



The Power Automate flow may look like this:





As you can see it is very easy to select the Order status Value from the Dynamic content list and the e-mail in the end will look like this:


In this case everything is totally fine and we can see the information we want to see. Now we will have a look how it will look like with Dataverse.

I created a similar flow that looks like this:


I also created a table with some test values:



However, the outcome is totally different:

In the e-mail above we can see the value of the option set that I defined before.



That is not the e-mail we want to send to our customer service because the customer service team does not know in which status the order is by reading the shown number. We need the label of the option set. For this we need to use a little trick.


First we need a "Get a row by ID action" inside our loop to get the current item again by adding the GUID as the row of our order table that we need. Then we will let the flow run one time to see the body of the outcome.


Here we will find two interesting points. First, we will see the number again which appeared as well in our e-mail and we will see the corresponding label.

What we need to accomplish our flow is exactly the difference between the two marked lines. We need to add @OData.Community.Display.V1.FormattedValue to the Order status field we added previously. We are going to achieve this by following the next steps.

Copy the Dynamic content we added previously and paste into the Expression field. Add "@OData.Community.Display.V1.FormattedValue" after your logical field name. In our case the logical field name is "tppd_orderstatus". You probably need to erase the "@{" in the beginning and "}" at the end. The expression should look something like this items('Apply_to_each_order_that_is_not_done')?['tppd_orderstatus@OData.Community.Display.V1.FormattedValue'].

In the end our action will look like this:

Don't mind the "items(...)" instead of a green Dataverse sign and the name of the field. Everything should be alright and the e-mail after starting the flow should look like this:


And that is exactly how it should look like!


I hope you enjoyed this article. Feel free to let me know what you think.

122 views0 comments

Comments


bottom of page