cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Ignore duplicate email addresses when sending emails

Hi I've built a flow that looks through my spreadsheet and sends 165 managers a table of their direct reports and what training they haven't completed yet.

 

This is what the Excel looks like:

Manager EmailReportOustanding training
manager.one@hotmail.comBilly Bob1, 2, 3, 4
manager.two@hotmail.comJoe Doe2, 6, 7
manager.one@hotmail.comSue Moe1
manager.one@hotmail.comRob Thob1, 2
manager.three@hotmail.comLazy Bones1, 2, 3, 4, 5, 6, 7, 8

 

This is my Flow:

Lebene_0-1617918380331.png

The manager receives a table like:

ReportOutstanding
Billy Bob1, 2, 3, 4
Sue Moe1
Rob Thob1, 2

 

My issue is that "manager.one@hotmail.com" will receive 3 duplicate emails instead of just the one. How can I prevent this? I've spent over an hour trying things like Initialize Variable/Union but I just get errors for that.

 

I appreciate any help, I'm still a novice trying to climb onto beginner so I'd appreciate if you don't assume I know what everything means as I'm still hack-jobbing things and not entirely understanding 'why' things happen yet.

 

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
Pstork1
Most Valuable Professional
Most Valuable Professional

Here's a sample set of screenshots

image.png

varmanager stores the last manager processed

varTraining is an array that stores the rows as they are processed.

image.png

Apply to Each processes each row.  If the varmanager is empty (first row processed) or the manager equals varmanager (last manager processed), then 

image.png

Append the row to the varTraining array and update the last manager processed (this is really just to set it after the first row where varManager is blank)

If the manager doesn't equal varManager do the No side

image.png

Convert the varTraining array into a table and send the email to the varmanager.  Then reset the varTraining array to the current row and varManager to the current row manager. (This is still inside the Apply to Each loop)

image.png

The Apply to each loop will now have sent emails to every manager except the last one.  So when you exit the loop Create one last html table and send it to the varmanager.  That will finish out the processing.

image.png



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

25 REPLIES 25
Pstork1
Most Valuable Professional
Most Valuable Professional

Sort the Excel data source by manager Email.  Then use a loop to process the entries.  For each loop check first to see if the manager email is equal to the one from the last loop.  If it is then process the entry (but don't send the email just append it to a string or array). If its a different manager then send the info in the stored string or array to the previous manager, save the current manager as the previous manager, and process the entry.  Loop and repeat.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Anonymous
Not applicable

Hi Pstork, thank you for your answer. Sadly, I just don't understand what it means.

 

Are you saying I should do several apply to each? I searched 'loop' and it didn't show anything. Where and at what stage am I doing all of this? I'm a novice, no humble facades here.

 

Thanks for your help

Pstork1
Most Valuable Professional
Most Valuable Professional

No I'm saying do one Apply to each after you have sorted the input by manager.  Then as you process each line check to see if the manager is different from the last line.  If it is then send the email.  If its not then store the information in some way and get the next line.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Anonymous
Not applicable

Thank you Pstork,

"Sort input by manager" - how? - I already have it sorted in the Excel file

"Process each line" - is this a component or a condition? How, where does it go in my screenshot I've provided?

"Store the information some way" - this is a manual operation or how is this done?

 

I've been working on this part for over 1 hour but I've been working on this Flow for the past 6.5 hours almost non-stop.  I would really appreciate a short guide or screenshot because I don't understand what you're saying stemming from my inexperience and fatigue.

 

Thank you again

Pstork1
Most Valuable Professional
Most Valuable Professional

1) its not sorted in the file you displayed.  the first and third row are manager.one and the second row is manger.two. There is an option to sort by a column when retrieving the rows from the Excel Table.

2) I'm assuming you are processing each row in the apply to each in your flow now.  I'm just explaining what conditions and actions you need to apply to each row.

3) You can either store the information by appending it to a string variable or adding it to an array.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Anonymous
Not applicable

Ok, I see. That table is just an example I made in this forum to display the duplication and data examples. It is sorted in Excel.

 

The apply each is sending the email

Lebene_0-1617930372865.png

 

I don't understand number 3.

 

I don't really think I'll understand what you're saying without a demonstration, you are speaking theoretically on what I could do, but as I don't possess the knowledge to make sense of it, it's really just many words for me but limited meaning. I struggle with instructions without examples in general, especially when I am lacking basic knowledge on the matter. Even a typed flow demonstration would help me, as I just don't understand where you want me to put these, at what stage, within where and with what syntax.

 

The flow I have now is:

Man. trig. flow -> List rows in table -> Select -> Create HTML Table -> Compose (with HTML table styling) -> Apply to each from excel value (Send an email v2).

 

Thanks again Pstork and I understand if you'd rather leave it here.

 

 

Pstork1
Most Valuable Professional
Most Valuable Professional

Here's a sample set of screenshots

image.png

varmanager stores the last manager processed

varTraining is an array that stores the rows as they are processed.

image.png

Apply to Each processes each row.  If the varmanager is empty (first row processed) or the manager equals varmanager (last manager processed), then 

image.png

Append the row to the varTraining array and update the last manager processed (this is really just to set it after the first row where varManager is blank)

If the manager doesn't equal varManager do the No side

image.png

Convert the varTraining array into a table and send the email to the varmanager.  Then reset the varTraining array to the current row and varManager to the current row manager. (This is still inside the Apply to Each loop)

image.png

The Apply to each loop will now have sent emails to every manager except the last one.  So when you exit the loop Create one last html table and send it to the varmanager.  That will finish out the processing.

image.png



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Anonymous
Not applicable

Hi Pstork, thank you for this detailed explanation.

 

In this run-through, this is the behaviour I experienced:

  1. My email has 4 duplicates but it sent no emails, ignoring them altogether
  2. My 2nd test inbox had 2 duplicates but sent 4 duplicate emails

 

I would want both inboxes to receive 1 email (there are 165 people who need to receive their individual email with varying number of reports).

 

I have attempted using this method: https://www.flowjoe.io/2020/12/17/remove-duplicates-from-a-power-automate-array-with-one-action/ and https://flowaltdelete.ca/2020/06/03/power-automate-expression-union-return-unique-values/ but although I manage to get it to run, the duplicates still occur.

Pstork1
Most Valuable Professional
Most Valuable Professional

I'm not sure how to help you further.  I created an excel table with the output you provided in your post and my example works perfectly for me.  I would go back and check your logic again.  You haven't followed the example I provided.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Anonymous
Not applicable

This is what I attempted in another method, not your method. It errors when I use the duplicate output as saying it does not find the row with the email or does not recognise the array.

screencapture-emea-flow-microsoft-manage-environments-Default-4473892f-71e0-46fc-8dec-273902b51349-flows-c66f260d-62ca-4d2d-a8dc-432eb4861cf7-2021-04-09-13_29_19.png

Anonymous
Not applicable

screencapture-emea-flow-microsoft-manage-environments-Default-4473892f-71e0-46fc-8dec-273902b51349-flows-c66f260d-62ca-4d2d-a8dc-432eb4861cf7-2021-04-09-14_40_38.png

 

I thought I did... is the last two HTML and Email in the wrong place?

Pstork1
Most Valuable Professional
Most Valuable Professional

It looks like the first condition you didn't add a blank value to the check on varManager.  It still says choose a value.  You need to check that against an empty string.

 

And in Create HTML table 3 you are processing varManager.  You should be processing varTraining just like you do inside the Loop.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Anonymous
Not applicable

Sorry about that, didn't realise the microsoft forums doesn't accept full screen screenshots. I will use the snipping tool:

1.

Lebene_0-1617976086642.png

2.

Lebene_1-1617976122409.png

 

3.

Lebene_2-1617976141030.png

 

4.

Lebene_3-1617976169601.png

 

5.

Lebene_4-1617976210680.png

 

 

Anonymous
Not applicable

Oh right, I misunderstood that as your screenshot also says 'choose a value' so I thought I leave it blank, how do I create the blank value - do I use 'null' in the expression? Also, why am I doing that?

 

I tried the null expression but my condition comes back false so nothing sends. I guess I'm trying to understand why my varManager would be blank, as I don't have any blank rows in my table.

 

Pstork1
Most Valuable Professional
Most Valuable Professional

Just use '' in the expressions tab to get a blank string



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Anonymous
Not applicable

Great thank you. I made those two changes but the behaviour I mentioned before still occurs.

 

I'm not sure what else could be the issue. My Excel table layout is exactly as I mentioned, albeit the training titles are actual words separated by commas, but that doesn't change anything even if I changed them to the numbers like my example.

 

Thanks a lot for your patience Pstork. I will pore over your screenshots and see if I missed anything else.

I also get this error for some of them 

Lebene_0-1617978668196.png

When I look at every instance of the run, all 6 was relating to the test inbox, not once of them related to my email address or the test reports in there.

 

I'll keep trying. Thanks again.

 

I wasn't supposed to do any advanced settings in my Listrows segment right?

Pstork1
Most Valuable Professional
Most Valuable Professional

Try making these changes.

1) When you initialize varManager initialize it to something like 'First'.  Then in the first condition check for that instead of null.

2) Look at your SetVariable2 again.  It doesn't match the text in my screenshot.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Anonymous
Not applicable

Ok, so in the value part of my Initialise Variable, I type ["First"]?

 

My SetVariable2 is your SetVariable - I can't see what the difference is, they both say varTraining in the Name, with: 

[
{
"Report": @{items('Apply_to_each')?['DirectReport']}.
"Outstanding Training": @{items('Apply_to_each')?['RemainingTraining']}
}
]

 

My SetVariable3 (your 2) both says varManager and ManagerEmail?

Pstork1
Most Valuable Professional
Most Valuable Professional

Did you change the condition to check for  ["First"]?

 

Also, the screenshot for your set variable 2 doesn't match mine.  Your screenshot shows

[
{"Report": @{items('Apply_to_each')?['DirectReport']}.
"Outstanding Training": @{items('Apply_to_each')?['RemainingTraining']}}
]

Instead of 

[
  {
    "Report": @{items('Apply_to_each')?['Report']},
    "Outstanding Training": @{items('Apply_to_each')?['Oustanding training']}
  }
]

whitespace makes a difference.

 

 



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Helpful resources

Announcements

Calling all User Group Leaders and Super Users! Mark Your Calendars for the next Community Ambassador Call on May 9th!

This month's Community Ambassador call is on May 9th at 9a & 3p PDT. Please keep an eye out in your private messages and Teams channels for your invitation. There are lots of exciting updates coming to the Community, and we have some exclusive opportunities to share with you! As always, we'll also review regular updates for User Groups, Super Users, and share general information about what's going on in the Community.     Be sure to register & we hope to see all of you there!

April 2024 Community Newsletter

We're pleased to share the April Community Newsletter, where we highlight the latest news, product releases, upcoming events, and the amazing work of our outstanding Community members.   If you're new to the Community, please make sure to follow the latest News & Announcements and check out the Community on LinkedIn as well! It's the best way to stay up-to-date with all the news from across Microsoft Power Platform and beyond.    COMMUNITY HIGHLIGHTS   Check out the most active community members of the last month! These hardworking members are posting regularly, answering questions, kudos, and providing top solutions in their communities. We are so thankful for each of you--keep up the great work! If you hope to see your name here next month, follow these awesome community members to see what they do!   Power AppsPower AutomateCopilot StudioPower PagesWarrenBelzDeenujialexander2523ragavanrajanLaurensMManishSolankiMattJimisonLucas001AmikcapuanodanilostephenrobertOliverRodriguestimlAndrewJManikandanSFubarmmbr1606VishnuReddy1997theMacResolutionsVishalJhaveriVictorIvanidzejsrandhawahagrua33ikExpiscornovusFGuerrero1PowerAddictgulshankhuranaANBExpiscornovusprathyooSpongYeNived_Nambiardeeksha15795apangelesGochixgrantjenkinsvasu24Mfon   LATEST NEWS   Business Applications Launch Event - On Demand In case you missed the Business Applications Launch Event, you can now catch up on all the announcements and watch the entire event on-demand inside Charles Lamanna's latest cloud blog.   This is your one stop shop for all the latest Copilot features across Power Platform and #Dynamics365, including first-hand looks at how companies such as Lenovo, Sonepar, Ford Motor Company, Omnicom and more are using these new capabilities in transformative ways. Click the image below to watch today!   Power Platform Community Conference 2024 is here! It's time to look forward to the next installment of the Power Platform Community Conference, which takes place this year on 18-20th September 2024 at the MGM Grand in Las Vegas!   Come and be inspired by Microsoft senior thought leaders and the engineers behind the #PowerPlatform, with Charles Lamanna, Sangya Singh, Ryan Cunningham, Kim Manis, Nirav Shah, Omar Aftab and Leon Welicki already confirmed to speak. You'll also be able to learn from industry experts and Microsoft MVPs who are dedicated to bridging the gap between humanity and technology. These include the likes of Lisa Crosbie, Victor Dantas, Kristine Kolodziejski, David Yack, Daniel Christian, Miguel Félix, and Mats Necker, with many more to be announced over the coming weeks.   Click here to watch our brand-new sizzle reel for #PPCC24 or click the image below to find out more about registration. See you in Vegas!       Power Up Program Announces New Video-Based Learning Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram. These include a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the image below to find out more!   UPCOMING EVENTS Microsoft Build - Seattle and Online - 21-23rd May 2024 Taking place on 21-23rd May 2024 both online and in Seattle, this is the perfect event to learn more about low code development, creating copilots, cloud platforms, and so much more to help you unleash the power of AI.   There's a serious wealth of talent speaking across the three days, including the likes of Satya Nadella, Amanda K. Silver, Scott Guthrie, Sarah Bird, Charles Lamanna, Miti J., Kevin Scott, Asha Sharma, Rajesh Jha, Arun Ulag, Clay Wesener, and many more.   And don't worry if you can't make it to Seattle, the event will be online and totally free to join. Click the image below to register for #MSBuild today!   European Collab Summit - Germany - 14-16th May 2024 The clock is counting down to the amazing European Collaboration Summit, which takes place in Germany May 14-16, 2024. #CollabSummit2024 is designed to provide cutting-edge insights and best practices into Power Platform, Microsoft 365, Teams, Viva, and so much more. There's a whole host of experts speakers across the three-day event, including the likes of Vesa Juvonen, Laurie Pottmeyer, Dan Holme, Mark Kashman, Dona Sarkar, Gavin Barron, Emily Mancini, Martina Grom, Ahmad Najjar, Liz Sundet, Nikki Chapple, Sara Fennah, Seb Matthews, Tobias Martin, Zoe Wilson, Fabian Williams, and many more.   Click the image below to find out more about #ECS2024 and register today!     Microsoft 365 & Power Platform Conference - Seattle - 3-7th June If you're looking to turbo boost your Power Platform skills this year, why not take a look at everything TechCon365 has to offer at the Seattle Convention Center on June 3-7, 2024.   This amazing 3-day conference (with 2 optional days of workshops) offers over 130 sessions across multiple tracks, alongside 25 workshops presented by Power Platform, Microsoft 365, Microsoft Teams, Viva, Azure, Copilot and AI experts. There's a great array of speakers, including the likes of Nirav Shah, Naomi Moneypenny, Jason Himmelstein, Heather Cook, Karuana Gatimu, Mark Kashman, Michelle Gilbert, Taiki Y., Kristi K., Nate Chamberlain, Julie Koesmarno, Daniel Glenn, Sarah Haase, Marc Windle, Amit Vasu, Joanne C Klein, Agnes Molnar, and many more.   Click the image below for more #Techcon365 intel and register today!     For more events, click the image below to visit the Microsoft Community Days website.      

Tuesday Tip | Update Your Community Profile Today!

It's time for another TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   We're excited to announce that updating your community profile has never been easier! Keeping your profile up to date is essential for staying connected and engaged with the community.   Check out the following Support Articles with these topics: Accessing Your Community ProfileRetrieving Your Profile URLUpdating Your Community Profile Time ZoneChanging Your Community Profile Picture (Avatar)Setting Your Date Display Preferences Click on your community link for more information: Power Apps, Power Automate, Power Pages, Copilot Studio   Thank you for being an active part of our community. Your contributions make a difference! Best Regards, The Community Management Team

Hear what's next for the Power Up Program

Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram, including a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the link below to sign up today! https://aka.ms/PowerUp  

Super User of the Month | Ahmed Salih

We're thrilled to announce that Ahmed Salih is our Super User of the Month for April 2024. Ahmed has been one of our most active Super Users this year--in fact, he kicked off the year in our Community with this great video reminder of why being a Super User has been so important to him!   Ahmed is the Senior Power Platform Architect at Saint Jude's Children's Research Hospital in Memphis. He's been a Super User for two seasons and is also a Microsoft MVP! He's celebrating his 3rd year being active in the Community--and he's received more than 500 kudos while authoring nearly 300 solutions. Ahmed's contributions to the Super User in Training program has been invaluable, with his most recent session with SUIT highlighting an incredible amount of best practices and tips that have helped him achieve his success.   Ahmed's infectious enthusiasm and boundless energy are a key reason why so many Community members appreciate how he brings his personality--and expertise--to every interaction. With all the solutions he provides, his willingness to help the Community learn more about Power Platform, and his sheer joy in life, we are pleased to celebrate Ahmed and all his contributions! You can find him in the Community and on LinkedIn. Congratulations, Ahmed--thank you for being a SUPER user!

Tuesday Tip: Getting Started with Private Messages & Macros

Welcome to TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   As our community family expands each week, we revisit our essential tools, tips, and tricks to ensure you’re well-versed in the community’s pulse. Keep an eye on the News & Announcements for your weekly Tuesday Tips—you never know what you may learn!   This Week's Tip: Private Messaging & Macros in Power Apps Community   Do you want to enhance your communication in the Community and streamline your interactions? One of the best ways to do this is to ensure you are using Private Messaging--and the ever-handy macros that are available to you as a Community member!   Our Knowledge Base article about private messaging and macros is the best place to find out more. Check it out today and discover some key tips and tricks when it comes to messages and macros:   Private Messaging: Learn how to enable private messages in your community profile and ensure you’re connected with other community membersMacros Explained: Discover the convenience of macros—prewritten text snippets that save time when posting in forums or sending private messagesCreating Macros: Follow simple steps to create your own macros for efficient communication within the Power Apps CommunityUsage Guide: Understand how to apply macros in posts and private messages, enhancing your interaction with the Community For detailed instructions and more information, visit the full page in your community today:Power Apps: Enabling Private Messaging & How to Use Macros (Power Apps)Power Automate: Enabling Private Messaging & How to Use Macros (Power Automate)  Copilot Studio: Enabling Private Messaging &How to Use Macros (Copilot Studio) Power Pages: Enabling Private Messaging & How to Use Macros (Power Pages)

Users online (3,867)