cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sienna28
Responsive Resident
Responsive Resident

Flow - How to remove duplicate email addresses from array variable?

In my flow, I have read email addresses from a list into an array variable.

 

I have some duplicate email addresses in there and I would like to keep one version only.

 

How can I remove duplicates and build up a string of email addresses, seperated by semicolons,  to use in the To: field of the email to be sent? 

 

So address1; address2;address3;address4 etc

 

Thank you

 

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
xyzzyx666
Resolver I
Resolver I

Hi @sienna28,

 

Could you please share a screenshot of your flow’s configuration?

You can try to use Union to remove the duplicate email address and use join with(;)to change "," to ";".

I have tested as next.

Step1: create one SP list(the list has two same eamil adress to test).

sp.png

 

Step2:Configure the flow: Use Union and Join

flow1.png

flow2.png

Step3:check it and then test

flow3.png

 

 

Hope this can be helpful.

 

BR,

xyz

 

View solution in original post

Anonymous
Not applicable

Thanks for your help in this thread @xyzzyx666

 

@sienna28 thanks for your post - can you review the information provided and let us know if it answers your question?

 

@Anonymous

View solution in original post

9 REPLIES 9
xyzzyx666
Resolver I
Resolver I

Hi @sienna28,

 

Could you please share a screenshot of your flow’s configuration?

You can try to use Union to remove the duplicate email address and use join with(;)to change "," to ";".

I have tested as next.

Step1: create one SP list(the list has two same eamil adress to test).

sp.png

 

Step2:Configure the flow: Use Union and Join

flow1.png

flow2.png

Step3:check it and then test

flow3.png

 

 

Hope this can be helpful.

 

BR,

xyz

 

Anonymous
Not applicable

Thanks for your help in this thread @xyzzyx666

 

@sienna28 thanks for your post - can you review the information provided and let us know if it answers your question?

 

@Anonymous

Anonymous
Not applicable

Hi,

 

Could you please share what the actions are? The screenshots provided are very hard to read.


@Anonymous wrote:

Thanks for your help in this thread @xyzzyx666

 

@sienna28 thanks for your post - can you review the information provided and let us know if it answers your question?

 

@Anonymous


 

hi, 

 

this solution doesn't show what you append to the array variable? 

 

also doesn't show the exact expression you used for Compose/Join?

 

could you please clarify?

@Jasong911 

 

Did you ever happen to figure out the rest of the expressions?

You can just perform the union against the same array to remove duplicates.

 

In the compose expression:

union(variables('emails'), variables('emails'))

 

to store the result back into an array just use a Set Variable and type "Outputs" in the dynamic content search option and locate the Outputs specific to the naming of the compose expression that you put the union code in.

ManiLive
Advocate I
Advocate I

A faster way to remove duplicates is to union the input array with an empty array.  This saves a lot of time with larger sets.
Initialize an empty array using Compose and use another Compose to union the input array with the empty array.

image.png

 

 

@xyzzyx666 the combination of union() and join() does the trick. Ingeniously simple, thank you!

 

Whatever I tried returned escaped double quotes as in 
'emailMessage/To' is required to be of type 'String/email'. The runtime value '"[\"username@company.com;\"]"' to be converted doesn't have the expected format 'string/email'.

 

I didn't need a compose action, actually:

 

Beat_0-1631296357729.png

 

Makes most sense! I shall definitely try that next time. Now I have just a couple of dozens of email addresses, no worries.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (4,095)