cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Advocate IV
Advocate IV

2 parallel loops dont work

Hi all,

I am trying use an approval to manage a loan. The user can choose either to extend the period of the loan or, if the item is returned, to close the loan. On the day of the deadline, an email is sent, every day thereon, as a reminder that the loan is due.

 

To do this I implemented 2 parallel loops. One loop contains the approval and the other waits for the deadline and sends an email every day. When the user approves by selecting "Extend Loan", the return date is extended. When they approve with "Return device", a flag is set to True which is the Loop Until condition of both loops.

 

The outcome is hard to debug, since loops cannot be debuged until they naturally teminate. In this case, the loop with the approval misbehaves and never ends. I have tried to set a 10 minute limit on both loops but this does not cause either to end.

 

For the sake of the test I changed all days into minutes just for debugging.

 

flow parallel loops.png

Strangely, the condition after the approval also does not work. When I select "Extend Loan" the "If no" branch works ok. But if I select "Return Device" in the approval the "if yes" does not appear to run (the email is not sent), however the variable loan_completed=True appears to get set, since the other loop actually terminates on this condition but the loop with the approval does not terminate and I receive another email for approval.

 

I have also tried moving "Do Until 2" in parallel to the create approval but the result is pretty much same.

 

Any ideas? thanks

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Dual Super User III
Dual Super User III

That's why I always enter it as an expression.  Case will make a difference if you match to text.  But the expression is an actual Boolean and always works.



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

View solution in original post

6 REPLIES 6
Highlighted
Dual Super User III
Dual Super User III

Is the approval directed to a single person or multiple people? I get the impression its to a single person.  If it is then I would suggest using Outcome instead of Responses.  That way you can avoid the first Apply to Each loop entirely.  for a single approval Outcome will be equal to either one of the individual responses that you've provided.

 

Second, I suggest putting the delay inside your Do Until Loop.  Start the loop, delay, then check whether the loop should be ended or not.  If not send the email reminder. Repeat.



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

Hi thanks for your reply

 

The approval is for a single person. The loop is because the approval is not just yes/no but can be used to extend the loan one or more times than finally to complete the procedure by selecting the Returned Device option. It needs a loop otherwise it will not issue an approval at every extension of deadline of the loan.

 

Yes, I initially had the delay inside the 2nd loop then took it out to help me debug. It doesn't make a difference. The 2nd loop terminates when at the right time but the email inside is never set.

The behavior is very wierd like some activities are just skipped entirely.

Highlighted
Dual Super User III
Dual Super User III

The problem with the first loop is that you are looping on the response.  If the approval is sent to one person there will never be more than one response.  But that response will be in a collection.  I think you believe that if the response is to extend the loan that the approval will still be live and another response can be sent.  It isn't unless you create and send another approval, which you don't. 



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

wow I posted a reply to this. I then edited the reply to correct an image and now the post is gone 😞

Highlighted

And so I discovered what was the main problem.

I was using "True" instead of "true" in my conditions and in my assignments.

I found a post of yours @Pstork1 in which you are recommending to enter true/false as an expression instead of as a string and indeed it worked. The case probably mattered as well.

Thanks

George

 

Highlighted
Dual Super User III
Dual Super User III

That's why I always enter it as an expression.  Case will make a difference if you match to text.  But the expression is an actual Boolean and always works.



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

View solution in original post

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.

Top Solution Authors
Top Kudoed Authors
Users online (16,305)