cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Beat
Level 8

Get Item within Do Until loop

I have the following flow, which is triggered when the status of an item is set to "Awaiting Resource Response". It waits for 3 days and then starts the following Do Until action as long as the status is not changed to anything else:

 

do until.png

- get item details for use in the email notification

- send a reminder email

- increment the counter of reminders sent

- write a log entry

- wait for 2 days

 

My problem is that the get item output is 2 days old, and even if the status is no longer "Awaiting Resource Response", one more reminder will be sent. How can I avoid that the Do Until loop runs one more time?

 

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Get Item within Do Until loop

Hi @Beat,

 

In general I triy to keep myu flows as simple as possible and aim to remove any steps that are not required. There might quite well be alternatives available. Your suggestion could quite well work, however do-Untils and condition stopping all code could be dangerous as you migth end up with no steps running inside the Do Until if you get the logic wrong.

View solution in original post

10 REPLIES 10
Super User
Super User

Re: Get Item within Do Until loop

Hi @Beat,

 

Do until will run until a certain condition so you will find that it runs and then waits in your flow. 

 

Why don't you move your delay action to the position just before the Get item?

Beat
Level 8

Re: Get Item within Do Until loop

I had the Delay after the Get Item because there is already an initial delay, before the Do Until loop, and I didn't want the two to add up. But of course, I can simply reduce that initial delay from 3 to 1 days, and then the first reminder is sent after 1 + 2 days, and then every two days. Perfect, so easy, just didn't get it. Thank you, will accept as a solution once successfully tested.

Beat
Level 8

Re: Get Item within Do Until loop

Hi @Pieter_Veenstra, moving the Delay action just before the Get Item action doesn't do the trick. Although the status may now be different, it still won't exit the loop, but complete the actions within the loop for one last time. Is there any way to avoid this?

Super User
Super User

Re: Get Item within Do Until loop

HI @Beat,

 

This is really why I try to avoid the single run flows. Do Until means that you will keep youw alive until the job's done. 

 

I find it a lot easier to contorl the flows by letting flows retrigger and let the flow chack how far it got in the over all process. This is also called state machine.

 

Anyway, back to your flow.

 

Reading through your history. I would trigger on the change of item. Do all your checks on your item .i.e. is the status that you want the flow to go into wait for?

 

Then do a delay 3 days. ( not do until)

 

Then check for the status again.

 

Beat
Level 8

Re: Get Item within Do Until loop

Hi @Pieter_Veenstra, I agree, but how do I re-trigger the flow after the delay of 3 days? My issue is that the reminder must go out if there was NO change to the item, while a change will likely indicate that no more reminders need to be sent and should not trigger that flow.

 

 

 

Super User
Super User

Re: Get Item within Do Until loop

Hi @Beat,

 

Maybe a single trigger state mahcine would work for you. I created a template in Flow for this.

 

https://veenstra.me.uk/2018/09/28/microsoft-flow-state-machine-template/

Super User
Super User

Re: Get Item within Do Until loop

I've created a blog post for this. Hopefuly this helps:

 

https://veenstra.me.uk/2018/10/23/microsoft-flow-sending-out-reminders/

Beat
Level 8

Re: Get Item within Do Until loop

Great thanks @Pieter_Veenstra, I actually met you here some time ago, which well contributed to my learning curve.

Because of the odd status sequence in the underlying SP list it would be too much effort. But what if I put a condition inside the do until loop, between get item and send reminder, and skip the subsequent steps if loop condition is no longer met?

Super User
Super User

Re: Get Item within Do Until loop

Hi @Beat,

 

In general I triy to keep myu flows as simple as possible and aim to remove any steps that are not required. There might quite well be alternatives available. Your suggestion could quite well work, however do-Untils and condition stopping all code could be dangerous as you migth end up with no steps running inside the Do Until if you get the logic wrong.

View solution in original post

Beat
Level 8

Re: Get Item within Do Until loop

The logic should always be right, indeed. The problem is dealing with the delay within the loop. You start a loop while condition is true. It doesn't matter if you put the delay before or after the get item. After the get item, you need to check if the condition that started the loop is still true, and exit if not. You can only exit by skipping all the remaining actions in the loop, or is there another way?

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

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 Kudoed Authors (Last 30 Days)
Users online (4,586)