Power Automate | Get Choice Label From Metadata
Microsoft is encouraging the replacement of traditional workflow processes with Power Automate (formerly called Microsoft Flow). And with that change, there are certain items where flows handle things differently, and we, as developers, need to find the best methods to develop solutions that contain flows.
This blog will surface a way that flows can expose the Choice column, in particular, the label. Many times, the label of the Choice is needed in addition to the value, but, in flows, the label is somewhat hidden and below the surface. For example, if we wanted to send an email to a customer and place dynamic values in the body of the email, the Choice label is not readily available. We need to expose the metadata of the Choice column to use throughout the flow. Let’s figure it out together.
Situation
You need to use a selected Choice label in your flow instead of the selected Choice value.
For this example, I needed to display a selected Choice label in an email instead of the Choice numeric value as these emails will be sent to customers and the numeric value would have no meaning.
Solution
The column in question is Industry on the Lead table. We can see from the below image, that it is a Choice column:

On the Lead form:

Create Flow
Summary
Here is a summary of the entire flow:

Create Solution
Navigate to the desired environment and create or find the solution. Here, I created the following solution:

Create Power Automate
From inside the solution, click New and then Cloud flow:

Choose Trigger
When the flow opens, select “When a row is added, modified, or deleted” as the trigger. Set the change type, table name, and scope.


I always like to save my flow as soon as possible, so I add a Compose action, enter the Name field into the Input value, provide my flow a name, and save.

Initialize Variable
We need to store the Choice label into a variable. Add new step, search for “initialize variable,” enter a name, set Type to String, and set value to null by using an expression.


We will set this value after we retrieve the table data and metadata; let’s do that.
Get Lead
Right after the trigger, click the + Insert a new step action and search for Get a row by id. Select Leads for Table name and enter the Lead Id by using the expression.

When completed, it should look like this:

The order of flow components is now:

Get Lead Metadata
Now to see what information we need to retrieve for the Industry Choice label, save the flow, and create a Lead, ensuring to enter a value for Industry.

Navigate to the flow run:

And view the results:

Expand the Get Lead action results and scroll down to the body section.
I usually copy all the contents in the body and paste into Notepad++ so I can view the information easier.
Search for “industry” and you will find something like this:

Set aside for now.
Set Variable
Edit the flow and add new step right after Initialize Industry action. Search for Set variable. Select the correct variable. Click in the value area and select Industry from the Get Lead dynamic content. It should look like this:

Here comes the fun part. Select the contents of the above value and paste into Notepad. It will look like this:

Remove the @ and the {}.
Navigate back to the Notepad++ where the Lead metadata resides from the previous run and grab the highlighted part of the following:

Paste right after industrycode, and the result will look like this:

Copy the whole thing, navigate back to the flow, remove the Industry you entered, click inside the value area, click the Expressions tab, paste the contents, and click OK.

The result will look like this:

Test
Since the flow has already run, we can test our new changes with previous data. Click Test at the top right, select Automatically, select a previous run, and click Save and Test.

We can see that the set variable worked perfectly:

Send Email
We have everything in place to build out our email body. After the Set Industry action, click New Step, search for Send an email (V2), select it, and fill out the required fields.
In the body of the email, we can enter the Industry variable result like this:

Click in the email body where you would like the value, ensure the dynamic content dialog box is open and search for Industry, and select it.
Final Test
Click Test at the top right, select Automatically, select With a recently used trigger, select the last run, and click Save and Test.
The flow has successfully run:

The email sent with the Choice label:

We have learned a nice feature of the table metadata and that we can use in our flows. This same concept will work for Two Options, Lookups, and more.
If you have any questions about Power Automate, please connect with us.
What are the steps in a CRM implementation? What are the biggest causes of failure? How long will it take?