cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
hkhan
Frequent Visitor

Stop Flow in the middle of approval process on condition

Hi All,

 

I have a flow that has 5 level of approvals. The flow workds on SP list with manual trigger. The way it works is that at every level of approval, when an approver gets an email, they also get a link to the item where they can go and add the email address of the approver at next level e.g.

Approve 1 gets email for approval. --> Approver 1 approves and updates the Email field for approver 2. 

 

This way the flow contiues and the approver 2 gets an email automatically. This is to be done at all 5 levels of approval.

The requirements have changed now that there may not always be 5 approvers. Sometimes only 2 or 3 may be needed. 

 

IS there a way I can put a condition that may stop the flow at any level a user would want. I believe the flow cannot be dynamically set to increase decrease level of approvers but maybe some one has an idea of how to create certain conditions that might stop the flow if the next level of approver email field is empty? 

1 ACCEPTED SOLUTION

Accepted Solutions
yashag2255
Dual Super User II
Dual Super User II

Hey @hkhan That is so bad that flow does not recognise null string. I just replicated the issue at my end it threw the same error to me as you are gtting. Here are two ways I found to solve it.

1. Check the length of the string and if it is 0 then trigger the condition:

expression:

length(variables('hasEmail'))

hasEmail is my variable name please replace this with yours.

2. Check if the string is empty and if true trigger the yes branch and if false then the no branch

expression:

if(empty(variables('hasEmail')), true, false)

In the above expression, the if condition will return true or false and so on the right side n your condition, you should put true. 

Please see the screenshot below:

ys.pngHope this Helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

5 REPLIES 5
yashag2255
Dual Super User II
Dual Super User II

HI @hkhan 

 

In your scenario as you are getting the email address for the next level approval from sharepoint, I would suggest you initialise a few variables and use them to check if they have a value then proceed to another apporval or else terminate the flow. Please refer to the screenshots below: 

asd1.png

 

asd2.png

Here you replace Base in the variable with the email column of your sharepoint. This is for the first level, and you can similarly replicate for the other levels, too. 

 

Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

hkhan
Frequent Visitor

Hi @yashag2255 

Thank you for your reply. I have tried your solution but I am getting the following error:


Capture.PNG

 

Here is how I set my flow:

Capture.PNG

 

Capture2.PNG

 


Even thought the "HasEmail" variable is null it still goes on to to process the wrong branch. 

Capture3.PNG

 

yashag2255
Dual Super User II
Dual Super User II

Hi @hkhan  Can you confirm what data is coming in the has email variable of your flow? Can you post a screenshot of the flow run on the action set variable and check if something is coming in?

hkhan
Frequent Visitor

Capture.PNG

 

Just for the kick...I changed the condition from:

 

 Capture.PNG

 

TO This:

 and it worked. Even though I can see that HasEmail variable is equal to null

Capture2.PNG

yashag2255
Dual Super User II
Dual Super User II

Hey @hkhan That is so bad that flow does not recognise null string. I just replicated the issue at my end it threw the same error to me as you are gtting. Here are two ways I found to solve it.

1. Check the length of the string and if it is 0 then trigger the condition:

expression:

length(variables('hasEmail'))

hasEmail is my variable name please replace this with yours.

2. Check if the string is empty and if true trigger the yes branch and if false then the no branch

expression:

if(empty(variables('hasEmail')), true, false)

In the above expression, the if condition will return true or false and so on the right side n your condition, you should put true. 

Please see the screenshot below:

ys.pngHope this Helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (1,250)