First Initialize Variable. Set the type to
array and call it emailAddresses.
Now add a
Compose. Use the expression
split(triggerBody()?['SendingStation'],',') assuming the list with the SendingStation column is the same one the flow is triggered from.
If in doubt, type split(,',') in the expression editor, place the cursor after the ( then click the dynamic content tab and find the relevant part by scrolling through and click OK.
Now add an
Apply to Each loop with the output of the Compose from earlier as its input. Inside the Apply to each put a
Filter array action.
The array to filter is the
value property of the Get items action where you get List 2. The filter condition is:
@equals(item()?['City'],trim(items('Apply_to_each'))) - Click Advanced, paste this in then you can click back to basic.
Now, Put in a
Condition. The condition is the expression
length(body('Filter_array')) is greater than 0
In the Yes branch, do
Append to array variable. Select the array you initialised earlier and the value to append is the expression
first(body('Filter_array'))?['EmailAddress']Now below the apply to each loop add an action called
Join. The array is the variable and the character to join on in ;
You can now use the output of the join as the To: input of an email. You might also want a condition before the email to ensure
length(variables('emailAddresses)) is greater than 0 so the email action does not fail.
------------------------------
Will Page
Technical consultant
Christchurch, NZ
------------------------------
Original Message:
Sent: Sep 21, 2021 05:08 PM
From: DeAnna Pitts
Subject: Working with Power Automate
Hello,
Newbie to Power Automate.
I am trying to create a email that will notify multiple city managers when a new record is created. I have two SharePoint list that I am working with. The first one contains all the information submitted for a request. The second Sharepoint list is the city and the DL list on who needs to receive the email.
My problem is I have a column in my first SharePoint list that has a concatenated value. My dilemma is how to break that up so I can grab the appropriate email addresses from my second list. Below are examples:
Sharepoint List 1: Sharepoint List 2:
SendingStation City EmailAddress
City1, City2, City3 City1 me@anywhere.com
City2 you@someplace.com
City3 them@thisplace.com
End results is, I want to pull out City1 and filter that in Sharepoint list 2 and grab the email address then continue looping through until I have all the addresses for each city. Recommendation?
Thanks,
DeAnn
DeAnna Pitts
Senior Technical Business Analyst