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

 

 

Anonymous
Not applicable

@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

 

Anonymous
Not applicable

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
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (4,777)