Retrieving OptionSet Labels from CDS data in a Cloud Flow / Power Automate / Flow is an extra step than just picking from the Dynamic Values. Check this post!!
Scenario
While working with data that is either a result of a Dataverse Trigger (on Create/Update) or Action like (Get record, list record), the OptionSet fields from CDS/Dataverse return the Values of the OptionSet instead of the Text Labels –
- Let’s say this is the OptionSet in Dynamics
- And when you pick the OptionSet field from CDS either from an Action or a Trigger like this
Let’s say I’m capturing this in a variable to show you
I’m storing this in a variable for this example to show you - I’ll capture the Value of the OptionSet i.e. the Value part
Result – - What needs to be displayed is the Label of the OptionSet! Let’s see how we can do this –
- Triggers
- Actions – List records (Inside Loops)
- Actions – Get record (Single record)
triggerOutputs() / triggerBody() to read the OptionSet values from Triggers
Let’s see how to read the OptionSet values from CDS Triggers, Create or Update –
- When a Flow is triggered using CDS/Dataverse Triggers (I’m using Common Data Service Environment(Current Environment) trigger), you can read the OptionSet value by using triggerOutputs() / triggerBody() function –
Here’s a triggerBody() example
Now, notice that the name of the field is cf_accounttype. So, the label in Triggers can be retrieved as _cf_accounttype_label and NOT cf_accounttype.
Same way, you can also use triggerBody() function instead as well to yield the same result
Here’s a post on triggerBody() / triggerOutputs() for your reference – Using triggerBody() / triggerOutput() to read CDS trigger metadata attributes in a Flow | Power Automate
items() to read the OptionSet values from Action Step – List Records (Multiple Records)
Let’s look at this example where you are retrieving multiple records using List Records and now, you apply a loop on each of those to read individual records.
- Assuming you are using List Records and you loop through the outputs of each of these records
- Now, the value is represented by items() function on the Loop that you are in i.e. Apply to each.
Hence, the function isitems('Apply_to_each')?['cf_accounttype@OData.Community.Display.V1.FormattedValue']
This will show the label of the OptionSet in the results
outputs() to read the OptionSet values from Action Step – Get a record (Single Record)
Similar to items() function, we can use outputs() function to read from the Output’s of the Get a Record Action from Common Data Service (Current Environment)
- Get an Account is a ‘Get a record’ Action in CDS/Dataverse Current Environment connector. It’ll only fetch a single record.
- Now, let’s look at how outputs() function, similar to items() function used in case of Loops is used.
Formula is –outputs('Get_an_Account')?['body/cf_accounttype@OData.Community.Display.V1.FormattedValue']
In the above scenario, I’m reading under body hierarchy for cf_accounttype@OData.Community.Display.V1.FormattedValue
Using JSON Parse to get the values
Finally, there’s also a method in which you can create a Parsed JSON from the Outputs
- Pick JSON from the Actions, it is under Data Operations connector and is a very popular one.
- Now, you’ll need to pass Outputs of the CDS Step to the Inputs of the Parse JSON step. Now, since you don’t already have a schema yet, Just put {} and save (else, you won’t be able to save)
- Now, Run the Flow once where the CDS step was successful and copy the Outputs from the Body
- Now, go to the same Parse JSON Step and click on Generate from Sample
- Now, paste the copied Body to generate the schema.
- Once you click OK, the schema will be generated.
- Finally, you can select the Parsed schema and use it as Outputs.
And it will appear as below –
Again, this will also show the same results as the above approaches.
Hope this helps!
Here are some Power Automate / Cloud Flow posts you might find helpful –
- InvalidWorkflowTriggerName or InvalidWorkflowRunActionName error in saving Cloud Flows | Power Automate Quick Tip
- Create a Team, add Members in Microsoft Teams upon Project and Team Members creation in PSA / Project Operations | Power Automate
- Setting Lookup in a Flow CDS Connector: Classic vs. Current Environment connector | Power Automate Quick Tip
- Adaptive Cards for Outlook Actionable Messages using Power Automate | Power Platform
- ChildFlowUnsupportedForInvokerConnections error while using Child Flows [SOLVED] | Power Automate
- Run As context in CDS (Current Environment) Flow Trigger | Power Automate
- Using outputs() function and JSON Parse to read data from missing dynamic value in a Flow | Power Automate
- Setting Retry Policy for an HTTP request in a Flow | Power Automate
- Make On-Demand Flow to show up in Dynamics 365 | Power Automate
- Task Completion reminder using Flow Bot in Microsoft Teams | Power Automate
- BPF Flow Step as a Trigger in CDS (Current Environment) connector | Power Automate
- Pause a Flow using Delay and Delay Until | Power Automate
Thank you!!