cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ryanrussell9
Level: Powered On

Dynamically exclude an Approver if they are the Submitter (Requestor)

Hello All, 

 

I'm stuck with trying to find a solution for this use case.

I'm working on a flow where a group of users can submit and approve request. The same users are a member of both groups (Requestor and Approver), however; the person submitting the request cannot approve the request.  

 

I'm looking for a solution where I can dynamically exclude a person from Approving a Request (not receive the approval email) if they Submitted the request. For reference, the request is triggered from a SharePoint list when a new item is created.  

 

How do I configure the Assigned To review node to dynamically exclude the user from approving a request they submitted?  

 

Thanks, 

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Dynamically exclude an Approver if they are the Submitter (Requestor)

What i do in this situation is to build a string array of all the approvals email addresses with the correct delimiter. You could then just using a replace function in a compose or directly in the approval action to replace the requests email with delimiter with nothing, thus removing them from the string.

View solution in original post

12 REPLIES 12
Dual Super User
Dual Super User

Re: Dynamically exclude an Approver if they are the Submitter (Requestor)

I suspect the easiest way is to rebuild the array.  Initialize an empty array for the Approvers.  Then iterate through the existing approvers array and compare each email to the current user's email. If it doesn't match add it to the new array. If it does match do nothing.  When the loop is done the new array will have all the user's emails except the current user.  Use that to send the approval.



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

Re: Dynamically exclude an Approver if they are the Submitter (Requestor)

Hello Pstork1, 

 

Very interesting solution. Do you think the array can read from a O-365 group or it will be best if the list of users is stored in a SharePoint list?

Dual Super User
Dual Super User

Re: Dynamically exclude an Approver if they are the Submitter (Requestor)

It would take another connection and a couple additional actions to get the members list of an O365 group, but there's no reason it wouldn't work either way.



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

Re: Dynamically exclude an Approver if they are the Submitter (Requestor)

What i do in this situation is to build a string array of all the approvals email addresses with the correct delimiter. You could then just using a replace function in a compose or directly in the approval action to replace the requests email with delimiter with nothing, thus removing them from the string.

View solution in original post

ryanrussell9
Level: Powered On

Re: Dynamically exclude an Approver if they are the Submitter (Requestor)

Hello, 

 

I'm a Power Automate newbie and I'm having trouble working with Arrays. 

The Array source (list of users) is a SharePoint list. The user names are in a Column type Person.

I believe I've successfully initialize the Array, the but the flow is failing at the condition and the start approval step to send the email to the Approver. 

 

Here is a screen shot of the failed flow and the actual flow. Your assistance is greatly appreciated!

 

Array Flow Error.JPGErrorArray Flow.JPGFlow

Super User
Super User

Re: Dynamically exclude an Approver if they are the Submitter (Requestor)

Hey,

You are going to create a approval object for each approver the way you have this configured. You need the start for approval object outside of the loop. You will need to process the array and pass into the approval object a comma delimited list of emails. The solution i provided above is by far easier than working with arrays, but it looks like you are on the right path.

ryanrussell9
Level: Powered On

Re: Dynamically exclude an Approver if they are the Submitter (Requestor)

Ok. With your approach, the Approval object will only contain one email address at a time, correct? I was thinking I want to populate the Array with all Approvers to send all Approver emails with the same object.  

 

As for updating an Array, should I use the Append or Set Variable object?

Super User
Super User

Re: Dynamically exclude an Approver if they are the Submitter (Requestor)

Hi Ryan, So what i suggest is to build a string that will end up like this:

 

  • user@domain.com; user2@domain.com; user3@domain.com; user4@domain.com;

 

You then do a replace i.e. replace('user3@domain.com;', '')

 

This would be used to remove the user3 that is the requestor for example (obviously use their dynamic email.

 

You would then end up with a string like: 

 

  • user@domain.com; user2@domain.com; user4@domain.com;

 

a variable cannot update its self, so you need to use a COMPOSE.

 

Pass the output of the compose into the approval object, and you can then choose either all must approve or first approve depending on your business case.

 

Hope that makes sense.

ryanrussell9
Level: Powered On

Re: Dynamically exclude an Approver if they are the Submitter (Requestor)

Hi Gristy, 

 

This makes logical sense, but I'm not sure about the objects for all of the steps. 

 

What object do I use to replace the string of emails? The idea would be to use the Get Item object to pull the list of emails from SP.  

 

Super User
Super User

Re: Dynamically exclude an Approver if they are the Submitter (Requestor)

In this order:

 

0. Intialize Variable -> Approvers 

1. Get Items

2. Append to String variable (Approvers)

    -> Insert Use (People Column Name) Email Dynamic Content

     -> add a ; on the end

3. Outside of the Apply to each that gets created use a Compose action with the replace expression

4. insert into start and wait for approval

 

If you get stuck happy to jump on a zoom and help you configure it. 

 

ryanrussell9
Level: Powered On

Re: Dynamically exclude an Approver if they are the Submitter (Requestor)

Hi Gristy, 

 

I am stuck on your step 3. Don't I need a if statement in order to know what to replace? Essentially, I need to remove the email address if it matches the email address of the requestor (which is the person who created the item and the flow trigger). Sure, a Zoom would be awesome. Thank you so much! 

Super User
Super User

Re: Dynamically exclude an Approver if they are the Submitter (Requestor)

Hey, 

 

You do not need a if statement, as you know who the requesters email is right ? as you are just removing them from the screen, no condition is needed. i.e. using the created by email.

Helpful resources

Announcements
firstImage

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

firstImage

Incoming: New and improved badges!

Look out for new contribution recognition badges coming SOON!

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

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Solution Authors
Top Kudoed Authors
Users online (6,465)