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
- 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.
- 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 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.
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.
Choosing the Department opstion set will result in the value of the departement , not its name.
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“.
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']
This formula will return the choice field text instead of the value.
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
- New Power Automate Designer Features
- How To Split String In Power Automate To Array?
- OData Filter Query Power Automate In SharePoint Get Items |
- How Power Automate Create Excel Table Dynamically? | Power Automate
- How To Make A Csv File Utf-8 Encoded? | Power Automate
- How Power Automate Create Excel Table Dynamically?
- How To Format Text In PowerApps? PowerApps Convert Text To Other Data Types
- Alternate Row Color In Gallery PowerApps: Simplest Way
- Check If PowerApps Contains Substring
- PowerApps Get Day Of Week Date
Join us
- Subscribe to Power Platform Geeks YouTube channel.
- Register to Saudi Arabia Power Platform User Group.