You are currently viewing How to get choice field text in power automate from Microsoft Dataverse?
Choice field label in power automate

How to get choice field text in power automate from Microsoft Dataverse?

One of the key features of Dataverse is the ability to use option sets, also known as choice fields.In this blog post, we will learn how to get choice field text in power automate from Microsoft Dataverse.

Option Sets in Dataverse

An option set is a predefined list of choices that users can select from when entering data into a field. These choices are presented as a dropdown list. For example an option set for Department that include “IT, HR, etc.”

In Dataverse there are two types of Option sets

  1. Global Option Sets: These are reusable option sets that can be used across multiple tables and fields. Changes to a global option set automatically reflect on all fields using it.
  2. Local Option Sets: These are specific to a single field within a table. They are useful when you don’t need to share across multiple fields.
get choice field text in power automate

get choice field text in power automate from Microsoft Dataverse

Choice columns in Dataverse are stored with both a value (integer) and a label (string). You may need to handle these appropriately in your flow.

image 4 | Power Platform Geeks

Sometimes, when working with Power Automate, we need to display the text value of an option set or choice field. Initially, we might try to insert the choice field name, but we will find that it returns the value of the choice set, not the text label as shown below.

image 5 | Power Platform Geeks

Choosing the Department opstion set will result in the value of the departement , not its name.

image 6 | Power Platform Geeks

So how we can get choice field text in power automate?

To do that lets have a look to the output of the option set value. You will that there are two fields related to the department one for text “cr52c_department@OData.Community.Display.V1.FormattedValue” and one for the value “cr52c_department“.

image 7 | Power Platform Geeks

We need to display the name of the department from the field “cr52c_department@OData.Community.Display.V1.FormattedValue” that actually contain the label text.

The solution will depend on from where we can get this value from the flow trigger or from an action within the flow.

dataverse choice column from An Action in power automate

When retrieving data, you can access both the value and the label of a choice column. In the following example we will access the label data from an action inside the flow.

So to get the Department name from the option set that is in the list rows action we can use the items function as shown below.

 items(action name ) ?['the name for the optionset odata']

So in our example the formula will be:

items('Apply_to_each')?['cr52c_department@OData.Community.Display.V1.FormattedValue']
image 8 | Power Platform Geeks

This formula will return the choice field text instead of the value.

image 9 | Power Platform Geeks

dataverse choice column from the Trigger in power automate

To get choice field text in power automate from the trigger we can use this formula:

triggerOutputs()?['body/cr52c_department@OData.Community.Display.V1.FormattedValue']

Conclusion

By following these steps, you can effectively retrieve and use the text of a choice field from Microsoft Dataverse either from triggers or from an action in your Power Automate flows. This approach ensures that you can leverage the human-readable labels of choice fields, enhancing the readability and functionality of your automated processes.

See Also
Join us

Heba Kamal

Microsoft MVP, MCT, Technical Speaker, Blogger, and Microsoft 365 and Power Platform Consultant.

Leave a Reply