Use Flow to update a Multi Select option set

By Adam Piercy

I was daydreaming a few days ago about Flow and how it could do so much more than out of the box classic Dynamics workflows. It got me thinking about some common issues we face with workflows and how we usually have to get creative to solve these gotchas. So, I asked myself "can Flow handle something like Multi-select option sets?". I set out to find out if it worked, and guess what? It does, and it works great. Read on to find out how I did it.


Multiselect Fields were a great addition with limitations

In 2018 Microsoft launched a great new feature as part of Dynamics 365 v9, the Multi-Select Option Set. This had been a long-awaited request by the user community to save a lot of customers the headache of building workarounds. However, whilst it answered some prayers, it was not fully-fledged and had its limitations, primarily around interacting with the field via workflows. Let's look at a simple example.
 

I have multiple product lines and I want to use a multi-select option set to capture what products the customer is interested in. Are they interested in the Apple Watch and the iPhone, for example? So I want a workflow to compare the values selected in the Multi-select Option Set and do something if my condition is met or not. Sounds simple, let's dig in.

So we open our old workflow engine in D365 and set a condition for when our multi-select option-set equals Apple Watches….

Oh, wait…

…the multi-select option set field is not available in the condition, it simply is not available to pick. Neither can we update it on the form.

GREAT!

Traditionally we would look for a workaround using standard option sets or lookups or start building a plugin to handle the requirement etc. Untidy and cumbersome for what should be a simple request. Multi-select ,therefore, gets a bad rap and are not as popular as they should be.

I have been using flow A LOT recently and I love it, it is a game-changer for anyone who is not adept writing C# or who wants a solution that the customer can look after moving forward with more transparency (in fact, for these reasons and its feature set, I think it can be a replacement in many cases for plugin code).

I was day-dreaming one day and got thinking, "Flow can do a lot that workflow can’t. Can it handle Multi-select Option Sets?"

So, I got to work and ran a test and guess what? It works. Yes, that’s right folks, you can run conditions and update a multi-select field in Dynamics 365/Common Data Service using Flow and here is how.

Step 1


Start by creating your multi-select field.

Set up the multi select field

Then set up a simple Flow with a Dynamics 365 trigger (could also be a CDS trigger), it can be on the record created or record updated, up to you and doesn't matter. Then add a Compose action and set the value as your Multi-select Option set field, we will use this Compose later. In my example there were two fields, one called "Test Multi-select" and "Test Multiselect Label", do not use the value "Test multiselect label". Using values means if you want to change the label you are free to without needing to update the flow (Also I couldn't get it to work using Label, it didn't bring back any values).

Setting up your flow
 

Step 2


Run a quick test to see that you bring back some values, you will notice that it brings back an array separated by a comma. Nice.

"Tip
Use this test moving forward as your trigger so you don't need to go back to D365 and keep updating the record. Stay in Flow from now on whilst testing. Simple."


Bring back the multi-select array
 

Step 3


Add a new compose action and put in the value we are comparing against. in my case 859270000 which is the Item I want to send an email for, this is "Compose 4" in my demo.

Enter value in your new compose action
 

Step 4


Set up your condition. Choose "Condition" as your action.
In the first box put the value returned from our trigger, in my case "Compose". Next, the operator should be "Contains" for obvious reasons (it will never equal if more than one) and in the right box put our new compose value from Step 3. We do this so that they are both the same "type" otherwise one is an integer and one a string and you will get errors. this avoids that. You could use an expression to transform your inputs but I find this way simpler and more transparent when scanning.

Set up your condition
 

Step 5


Add your steps if your condition is met or not. For this demo I have shown that you can update  the Multi-select field on a Dynamics 365 record with your new value. You need to mindful of the existing fields already so use your initial"Compose" and using Concat() expression join your two Composes used earlier. like so:

concat(outputs('Compose'),',',outputs('Compose_4'))

Update D365 record

Step 6


Test it and see that it works, beautiful.

Before, no item.

Successful Flow

Updated, Item 1 is added


This is just a small example but using the power of Flow you can now do all sorts with your Multi-Select field such as send emails, update another record etc.

Pretty cool, eh?