The following was the user requirement.
The question was the user had the weird string stored in the Multi People Picker Field.
If you look closely at the sample string the “i:0#|membership|” is prefixed before all the emails. The question is how to get just emails with the array of emails. For a developer, it may not be difficult. But for a no-code citizen developer, it will be tricky. This blog post will explain step by step how to extract emails by using two string functions “concat” and “split”.
For other function reference, please book mark url https://aka.ms/LogicExpressions.
Step by Step Solution
Step # 1 Create a manually triggered flow with a Var1 variable.
Step # 2 Now we will add compose to split the string by ‘;’ (semicolon) character.
split(variables('Var1'), ';') The above expression will provide the following output. [ "i:0#|membership|Lisa.email@example.com", "i:0#|membership|Bart.firstname.lastname@example.org", "i:0#|membership|Marj.email@example.com", "i:0#|membership|Homer.firstname.lastname@example.org" ]
Step # 3 Iterate over the above compose output and split the each item in array on a pipe character ‘|’.
split ( item(), '|') [ 2 ] The above function will split on a pipe character for each items in the array. e.g. for "i:0#|membership|Lisa.email@example.com" the out put will be just email i.e. "Lisa.firstname.lastname@example.org". First the split will create and array as [ "i:0#", "membership", "Lisa.email@example.com" ] after that we are selecting the third element of the array. Note: the array is zero indexed so the third element will be 2.
NOTE: The final Compose “FinalArrayOfEmailsCompose” outside of the Apply each is a trick for collecting all values in the array.
The trick is make sure you are using inner loop’s compose as an input to it. Like following
So when workflow runs the output of the final compose will look like the following.
The final output is converted to required array with emails. Also we looked at the technique of Compose outside of Apply Each and collecting Compose values defined in the loop.