web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :

How to utilize Dataverse multiselect Choice column metadata in Power Automate

Bhavesh Shastri Profile Picture Bhavesh Shastri 261

Dataverse multiselect choice column type metadata has labels and corresponding integer values. While labels are used for the user interface, internally the system uses the corresponding integer values. Integrating services/systems are also required to use the integer values.

For example, the Dataverse Connector requires integer value inputs while creating or updating records that has multiselect choice columns values.

Screenshot 1:

Dataverse-choices-metadata-in-Power-Automate_2D00_1.jpg

This integer input requirement could make it challenging to author and maintain your Flows when the source system is only providing the labels and does not have the integer values. For example, The Microsoft Forms only has text labels. In such scenarios, you can hard-code the integer values mapped to the text labels while creating or updating records in Dataverse from the Flow, but hard coding is not ideal.

The Dataverse Web API can come in handy, using which you can retrieve the complete metadata. Below are the request and response examples in screenshot 2 and 3.

 Screenshot 2:

4087.Dataverse-choices-metadata-in-Power-Automate_2D00_2.jpg

Screenshot 3:

Dataverse-choices-metadata-in-Power-Automate_2D00_3.jpg

As you can see, the Web API response has much more information along with the label and the integer value for each value in the Choice column. You can use choice options from the response body by using the expression:  body('Invoke_an_HTTP_request_-_Get_Choices')?['Options']

and put it through an ‘Apply to each’ loop:

Screenshot 4:

 Dataverse-choices-metadata-in-Power-Automate_2D00_4.jpg

Inside the loop, parse the option as JSON so subsequent action(s) can refer the Value and the Label. You can generate the schema using one of the option objects from the response body.

Screenshot 5:

 Dataverse-choices-metadata-in-Power-Automate_2D00_5.jpg

The next action is to append the Label and the Value from the “Parse Current Choice JSON ” output of the current item using these expressions; refer to screenshot 6 for visual.

body('Parse_Current_Choice_JSON')?['Label']?['LocalizedLabels'][0]?['Label']

body('Parse_Current_Choice_JSON')?['Value'] 

Screenshot 6:

Dataverse-choices-metadata-in-Power-Automate_2D00_6.jpg

Upon loop completion, the “choicesMetadata” array looks like screenshot 7:

Screenshot 7:

Dataverse-choices-metadata-in-Power-Automate_2D00_7.jpg

I am attaching a sample cloud Flow following the above method. This flow can be triggered manually by providing the API URL and the choice column schema name. When executed, it returns an array which includes the labels and the corresponding integer values that you can consume in your parent flow by parsing it as JSON; like screenshot 8.

Screenshot 8:

 Dataverse-choices-metadata-in-Power-Automate_2D00_8.jpg

Hope this helps!

Bhavesh Shastri

Comments

*This post is locked for comments