How to retrieve CDS Option Set Label Name?
This is something often mentioned in Power Automate community about how to retrieve the option set label name? There are different ways you can retrieve this. It's all depends on the connector you using in your Power Automate Step.
When you create an Option set it allow you to include drop down lists of fixed values to a user within your app to ensure data consistency. Behind the scene it stores the name and a numeric value.
Power Automate actions steps such as Get or List records retrieve the option set numeric values. Here are the ways you could retrieve the option set label name.
There are two types of CDS connectors available in Power Automate.
(a) Common Data Service
(b) Common Data Service (Default Environment)
There are differences between these connectors.
If you using Common Data Service Connector you can directly get the option set name from List or Get Record. By default dynamic property shows the option set value only. See below in my example Type (Option Set) shows the dynamic property as Type Value which is the numeric value stored under the database. Label names are not shown under the Dynamic content.
If you check your runtime history of flow Power Automate step Get or List action, here you can see the label names are retrieved.
You can use the expression to retrieve this
If you using the List action then you can declare a compose action step, click the expression and type the following:
Using the the above technique you can retrieve the option set label names. The same technique works with D365 connector as well.
The above technique won't work with Common Data Service (Default Environment) Connector. It only retrieves the Option Set numeric values. So how do we retrieve the label names for default environment connector?
CDS stores the option set details (Label Name & Value) under a system entity called StringMaps. This entity is not accessible via CDS entity interface (PowerApps > Data > Entities) but available via Power Automate action steps.
To retrieve the option set label name you need to know couple of things before hand. Entity name where lookup is defined, lookup attribute name and value of the attribute (numeric value)
Execute the above list record which will retrieve the label name 'Value'. See below.
Thanks for reading my blog.