cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Teresa24486
Super User
Super User

Send email to user based on a department column value

Hi,

How do I send email to user based on a department column value on dataverse? Have a table with name, dept, email address:

NameDeptEmail
Test1ITTEST1@abc.com
Test2HR TEST2@abc.com
Test3IT TEST3@abc.com
Test4Marketing TEST4@abc.com

Based on the above table I need all the users addressed to a single dept to go out as an email from the TO field on email connector. Right now it is picking individual email addresses and sending to departments. Eg.: the email should go to Test1;Test3 for IT on a single email. Appreciate your inputs.

1 ACCEPTED SOLUTION

Accepted Solutions
DamoBird365
Super User
Super User

Hi @Teresa24486 

 

I have copied your table into excel, same idea, first part is listing the rows, performing a select action using "text mode" in order to get the dept in an array and then using union in a compose to create a list of unique depts.

 

DamoBird365_0-1633167375244.png

2nd stage is an apply to each on the unique departments, filter the list rows array where the dept is equal to current item (i.e. the unique dept 1of 3).  Then using a select where the from is the body of the filter and the map (text mode again) is item()?['email'] (you will have to type the expression), you can then join the array of emails with a smie colon and use in an email.

 

DamoBird365_1-1633167458188.png

 

The output is like so:

DamoBird365_2-1633167553259.png

If you are new to arrays, take a look here https://youtu.be/6nJSUNh579w

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Cheers,
Damien


P.S. take a look at my new blog here and like & subscribe to my YouTube Channel thanks 😉

 

View solution in original post

1 REPLY 1
DamoBird365
Super User
Super User

Hi @Teresa24486 

 

I have copied your table into excel, same idea, first part is listing the rows, performing a select action using "text mode" in order to get the dept in an array and then using union in a compose to create a list of unique depts.

 

DamoBird365_0-1633167375244.png

2nd stage is an apply to each on the unique departments, filter the list rows array where the dept is equal to current item (i.e. the unique dept 1of 3).  Then using a select where the from is the body of the filter and the map (text mode again) is item()?['email'] (you will have to type the expression), you can then join the array of emails with a smie colon and use in an email.

 

DamoBird365_1-1633167458188.png

 

The output is like so:

DamoBird365_2-1633167553259.png

If you are new to arrays, take a look here https://youtu.be/6nJSUNh579w

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Cheers,
Damien


P.S. take a look at my new blog here and like & subscribe to my YouTube Channel thanks 😉

 

Helpful resources

Announcements
MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

PA Survey Carousel Image.png

We want to hear from you!

If you are a small business ISV/Reseller, share your thoughts with our research team.

Users online (3,131)