cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
stevenbranigan
New Member

Adding condition to email flow - if user = x, email = y, else email = user email

Hi,

 

I am very new to flow and I have just learned about the compose action that allows me to manipulate date formats.


I have an email flow that emails users when a new item is created in a sharepoint list.  One of the fields on the sharepoint form is responsible.  When a new item is created an email is fired off to the responsible email.


I've got a requirement though that when a responsibles email is a particular email that the new item created email should go to a shared email inbox.  Does that make sense?

 

I have a group of users that this is required for, a sales team.  The sharepoint list is an incoming call register that the customer service team work with.  They accept calls and forward customer service requests to the relevant dept / person.  When its a sales call the email is sent to sales@email.com.  Naturally the sales team is multiple users and they pool the requests and answer as they can.

 

Is there a way to manipulate the TO field in the send email flow so that if user = x, send email to sales@email.com, else send it to responsibles email?

 

Hoping there is.


Appreciate any help, and thanks in advance.

 🙂

 

Steve

2 ACCEPTED SOLUTIONS

Accepted Solutions
Microsoft
Microsoft

Re: Adding condition to email flow - if user = x, email = y, else email = user email

Does this kind of flow satisfy your needs?

When some fields of newly added item is x, send email to sales@email.com, otherwise send email to responsibles@email.com

 

conditionemail.png

 

Thanks

View solution in original post

Microsoft
Microsoft

Re: Adding condition to email flow - if user = x, email = y, else email = user email

I searched from workflow definition language, https://docs.microsoft.com/en-us/rest/api/logic/definition-language

 

Probably this is a solution in advanced mode: 

 

@and(@equals(triggerBody()?['user'], 'x'),@equals(triggerBody()?['user2'], 'y'))

 

 

 Thanks

 

View solution in original post

7 REPLIES 7
Microsoft
Microsoft

Re: Adding condition to email flow - if user = x, email = y, else email = user email

Does this kind of flow satisfy your needs?

When some fields of newly added item is x, send email to sales@email.com, otherwise send email to responsibles@email.com

 

conditionemail.png

 

Thanks

View solution in original post

Highlighted
stevenbranigan
New Member

Re: Adding condition to email flow - if user = x, email = y, else email = user email

Thats exactly what I was looking for @telu, thanks for your help.


Do you know if it's possible to put multiple clauses into the value field of a condition?


Can it be done as comma separated, or semi-colon separated?

 

Microsoft
Microsoft

Re: Adding condition to email flow - if user = x, email = y, else email = user email

I searched from workflow definition language, https://docs.microsoft.com/en-us/rest/api/logic/definition-language

 

Probably this is a solution in advanced mode: 

 

@and(@equals(triggerBody()?['user'], 'x'),@equals(triggerBody()?['user2'], 'y'))

 

 

 Thanks

 

View solution in original post

stevenbranigan
New Member

Re: Adding condition to email flow - if user = x, email = y, else email = user email

@telu You're a jedi!  Not only have you given me the solution for this one (fish)... you've also given me the link to the documentation that I was looking for in another thread (fishing rod)...  😄


Thanks mate, really appreciate your help!

jf82
Regular Visitor

Re: Adding condition to email flow - if user = x, email = y, else email = user email

This solution works with 2 choices, but if you have more than 5 it doesn't seem to work (Flow allows for 5 nested conditions). Any options you may have found for that? 

Sparrowhawk Advocate III
Advocate III

Re: Adding condition to email flow - if user = x, email = y, else email = user email

Sorry to necro an old thread, but if anyone else is seeing this and has a similar issue, one thing you could do is make a string variable that you can use to build a list of email addresses separated by ; that you use later on in your email connector. It could be initialized to empty, then you could use a switch case (a list of what to do when the value of Responsible equals certain values) that would add email addresses and a ";" to the string.

 

The pseudo-code would be something like this

 

Make an empty string emailRecipients

 

Look at "Responsible" on the item

 

If "responsible" is x, append a certain email address + ";" to the emailRecipients

 

If "responsible" is y, append a different email address + ";" to emailRecipients

 

Send email to the value of emailRecipients variable

craigyappert
Frequent Visitor

Re: Adding condition to email flow - if user = x, email = y, else email = user email

Another option is to use a Switch Control and switch on different emails .. then you can have as many as you want (well as many as you can effectively manage) and then use the default switch statement as your fall thru.

Helpful resources

Announcements
firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Automate Community!

firstImage

Now Live: Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Community Summit North America

The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Users online (7,864)