Power Automate Desktop Go to label

  • Home
  • Blog

Power Automate | Get Choice Label From Metadata

By July 7th, 2021

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. Lets 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:

Power Automate Desktop Go to label

On the Lead form:

Power Automate Desktop Go to label

Create Flow

Summary

Here is a summary of the entire flow:

Power Automate Desktop Go to label

Create Solution

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

Power Automate Desktop Go to label

Create Power Automate

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

Power Automate Desktop Go to label

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.

Power Automate Desktop Go to label
Power Automate Desktop Go to label

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.

Power Automate Desktop Go to label

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.

Power Automate Desktop Go to label
Power Automate Desktop Go to label

We will set this value after we retrieve the table data and metadata; lets 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.

Power Automate Desktop Go to label

When completed, it should look like this:

Power Automate Desktop Go to label

The order of flow components is now:

Power Automate Desktop Go to label

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.

Power Automate Desktop Go to label

Navigate to the flow run:

Power Automate Desktop Go to label

And view the results:

Power Automate Desktop Go to label

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:

Power Automate Desktop Go to label

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:

Power Automate Desktop Go to label

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

Power Automate Desktop Go to label

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:

Power Automate Desktop Go to label

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

Power Automate Desktop Go to label

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.

Power Automate Desktop Go to label

The result will look like this:

Power Automate Desktop Go to label

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.

Power Automate Desktop Go to label

We can see that the set variable worked perfectly:

Power Automate Desktop Go to label

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:

Power Automate Desktop Go to label

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:

Power Automate Desktop Go to label

The email sent with the Choice label:

Power Automate Desktop Go to 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.

How to Prepare for a Successful CRM Implementation

11 things you need to consider (and 1 you don't) before implementing a CRM system.

Get eGuide
Categorized In:
Dynamics CRM, Microsoft Dynamics, Power Automate Tips & Tricks, Power Platform

How Do You Prep for a CRM Implementation?

Get eGuide

Author

Power Automate Desktop Go to label

Gary Harrison

As a Solution Specialist, Gary engages with his clients to streamline business processes and enable business intelligence through the implementation of Microsoft Dynamics CRM/D365 Customer Engagement.

More from Gary Harrison
By Andrea Oklobdzija January 7, 2022

How to Create a Calculated Field in Dynamics 365 (CRM)

By Pierre Manaigre December 22, 2021

Power Apps Licensing

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. Lets 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:

Power Automate Desktop Go to label

On the Lead form:

Power Automate Desktop Go to label

Create Flow

Summary

Here is a summary of the entire flow:

Power Automate Desktop Go to label

Create Solution

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

Power Automate Desktop Go to label

Create Power Automate

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

Power Automate Desktop Go to label

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.

Power Automate Desktop Go to label
Power Automate Desktop Go to label

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.

Power Automate Desktop Go to label

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.

Power Automate Desktop Go to label
Power Automate Desktop Go to label

We will set this value after we retrieve the table data and metadata; lets 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.

Power Automate Desktop Go to label

When completed, it should look like this:

Power Automate Desktop Go to label

The order of flow components is now:

Power Automate Desktop Go to label

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.

Power Automate Desktop Go to label

Navigate to the flow run:

Power Automate Desktop Go to label

And view the results:

Power Automate Desktop Go to label

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:

Power Automate Desktop Go to label

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:

Power Automate Desktop Go to label

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

Power Automate Desktop Go to label

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:

Power Automate Desktop Go to label

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

Power Automate Desktop Go to label

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.

Power Automate Desktop Go to label

The result will look like this:

Power Automate Desktop Go to label

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.

Power Automate Desktop Go to label

We can see that the set variable worked perfectly:

Power Automate Desktop Go to label

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:

Power Automate Desktop Go to label

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:

Power Automate Desktop Go to label

The email sent with the Choice label:

Power Automate Desktop Go to 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.

How to Prepare for a Successful CRM Implementation

11 things you need to consider (and 1 you don't) before implementing a CRM system.

Get eGuide