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:
-
When an Account is created
-
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:
First, initialize an array variable and input the value in the following format:
[ { key: "<key1>", value: "<value1>" },{ key: "<key2>", value: "<value2>" } ]
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.
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']
.