web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Apply to Each conditio...
Power Automate
Unanswered

Apply to Each condition need to run only once

(0) ShareShare
ReportReport
Posted on by 144

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

Categories:
I have the same question (0)
  • ScottShearer Profile Picture
    25,270 Most Valuable Professional on at

    @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.

     

     

     

  • HarishaAkkil Profile Picture
    144 on at

    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

     

  • v-alzhan-msft Profile Picture
    on at

    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.

  • HarishaAkkil Profile Picture
    144 on at

    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

  • v-alzhan-msft Profile Picture
    on at

    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.

  • HarishaAkkil Profile Picture
    144 on at

    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 

  • v-alzhan-msft Profile Picture
    on at

    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.

  • HarishaAkkil Profile Picture
    144 on at

    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

  • v-alzhan-msft Profile Picture
    on at

    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.

  • HarishaAkkil Profile Picture
    144 on at

    Hi Alice,

     

    Yes I am still not able to find an answer.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard