A quicker method to map different option set values in Flow

2020-05-01

If you want to map input from one CDS option set to another with the same values in Flow, all you have to do is map the corresponding field - easy. However, if you have two different option sets with different values, you can either use a Condition or a Switch control. These controls can work in some scenarios, but can become tedious in other scenarios.

Consider the following scenario:

  1. When an Account is created
  2. Update the relationship type of all related Contacts based on the relationship type of the Account, with the following mapping (abbreviated for demonstration purposes):
Account relationship type value Contact relationship type value
253210000 154190001
253210001 154190002

The data operation Filter array can provide an alternative to the Condition and Switch controls in this scenario.

Let's start with the end result of the complete Flow:

Flow with Filter array data  operation Flow with Filter array data operation

First, initialize an array variable and input the value in the following format:

[ { key: "<key1>", value: "<value1>" },{ key: "<key2>", value: "<value2>" } ]

Initialize array variable Initialize array variable

This array variable uses the mapping we set out to create. Then, use a Filter array data operation to find the key in your mapping based on the relationship type.

Filter array Filter array

In the final Update Contact action, the body of the Filter array can be used to retrieve value corresponding to the key by using the expression body('Filter_array')?[0]?['value'].

Mapping the Filter array Mapping the Filter array
Common Data ServiceFlow

How to actually list ALL CDS records in Flow