cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper II
Helper II

Apply to Each condition need to run only once

Hi Team,

 

I am building a flow, such that when an email (external mail) got received, it triggers the flow, by sending the approval mail to the Recipient (internal user). And there exists a condition, if the To address from the external mail got more than one internal user, it should pick up only one internal user for the approval.

What I do is, for Audit purpose, I am creating an item in Sharepoint (which stores Message Id, Recipients Outcome,etc). Below is the screen shot of my flow.

 

Splitting the Recipients address - 

 

1.jpg

 

Checks the splitted Recipients address that contains internal domain address?

 

2.jpg

 

 

If yes, it is checking for the condition, if the sharepoint item has update - that if the title is equal to unique message id and (response is either approved/rejected) the flow should not continue to send email to the second internal user.

 

Meaning, here the approval mail should go to only one user, that's why i am checking the condition from SharePoint. but it is not working.

 

3.jpg

 

 

Why the condition fails?

Is there any other way to run the the approval mail only once? Since it is placed inside the Apply to each i am unable to terminate the flow as well.

 

Thanks for your help.

Thanks,

Harisha

10 REPLIES 10
Highlighted
Super User III
Super User III

Re: Apply to Each condition need to run only once

@HarishaAkkil 

I'm sure that it's me, but I don't totally understand your logic...

Howeverm have you considered using the first() expression after you split the email addresses rather than having an additional check? The first() expression will give you the first element in an array  - so it will give you the first email address from the output of your split.  So, it doesn't matter if there is a single email address or multiple addresses, you always get the first one.

 

 

 

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

Scott
Highlighted
Helper II
Helper II

Re: Apply to Each condition need to run only once

Hi @ScottShearer ,

 

So, there will be emails triggered from external domain (gmail, yahoo). Suppose say, there will be multiple recipients in the mail. 

For example: The To in the email is addressed to - user1@gmail.com,  user2@internaldomain.com,  user3@yahoo.com,  user4@internaldomain.com . Now I need to send the email for approval for user2 no need  to send approval to user4. So only one internal user from the recipients mail address has to get the approval. 

So what I am doing, after splitting the mail address, I am checking for the condition if the address of the email contains internal domain name and applying condition to send mail for approval. Since it is running under the Apply to each condition, it is sending approval mail to both the user2 and user4. That is the problem.

 

Hope you understand. If you still did not have a clear idea please feel free to speak out.

 

Thanks,

Harisha

 

Highlighted
Community Support
Community Support

Re: Apply to Each condition need to run only once

Hi @HarishaAkkil ,

 

I agree with @ScottShearer 's suggestion.

If you want to run the apply to each only once, you should keep the array has only one item in the input field of the Apply to each.

You could take a try with the first or last function before the apply to each.

 

And if you would keep the array with multiple emails in the apply to each and want the Apply to each to stop running when the special email address is found, please let me know and I would provide the workaround.

 

Best Regards,

Alice

 

Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Highlighted
Helper II
Helper II

Re: Apply to Each condition need to run only once

Hi @v-alzhan-msft ,

 

If I want to take the first internal user from the array, could you please help me with the code?

For example - user1@gmail.com,  user2@internaldomain.com, user3@internal domain.com, user4@yahoo.com  

How should I write the first or last function in such a way it takes the user2 alone?

 

Thanks,

Harisha

Highlighted
Community Support
Community Support

Re: Apply to Each condition need to run only once

Hi @HarishaAkkil ,

 

You could refer to screenshot below to the email address:

1.png

split(variables('test'),', ')
first(skip(outputs('Compose'),1))

 

1.png

 

 

Best Regards,

Alice

 

Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Highlighted
Helper II
Helper II

Re: Apply to Each condition need to run only once

Hi @v-alzhan-msft ,

 

Thanks for your reply. I would like to clarify on the formula - 

first(skip(outputs('Compose'),1))

means it does skip the first output right? Since we know the internal user is in second place, we are skipping the first output. But if we don't know the place where internal domain user is?

 

Please do tell me if you still didn't get what my request is.

 

Thanks,

Harisha 

Highlighted
Community Support
Community Support

Re: Apply to Each condition need to run only once

Hi @HarishaAkkil ,

 

You must know the place that email you need, or how can the flow know what is the needed one?

 

Best Regards,

Alice

 

Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Highlighted
Helper II
Helper II

Re: Apply to Each condition need to run only once

Hi @v-alzhan-msft ,

 

Yes that is the problem I am facing. When an email comes it should automatically find the internal user domain and send the notification. I should not manually go and check in which place the internal domain user is.

 

Thanks,

Harisha

Highlighted
Community Support
Community Support

Re: Apply to Each condition need to run only once

Hi @HarishaAkkil ,

 

Does your issue still exists?

 

Best Regards,

Alice

 

Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Highlighted
Helper II
Helper II

Re: Apply to Each condition need to run only once

Hi Alice,

 

Yes I am still not able to find an answer.

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Upcoming Events

Experience what’s next for Power Automate

See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Top Solution Authors
Top Kudoed Authors
Users online (7,427)