cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
New Member

[Do Until] goes trough the first run on the loop and doesn't work

Hello everyone,

I'm trying to build a flow with the following characteristics:

- when someone creates a new item in a sharepoint list, the flow is triggered (and it does stuff related to approvals, etc)

- inside the flow, I would like to have a Do Until loop that runs every 3 hours, to check if the item that triggered the flow still exists. If it doesn't the entire flow will be terminated.

 

The problem I have is that once the flow is launched, the Do Until only loops 1 time, and then it goes through to the next step as if the condition wouldn't work.

 

Here are the details of my flow:

 

I initialize a variable called item_exists and set it to falseI initialize a variable called item_exists and set it to false

Then onto the Do Until:

 

s3.PNG

 

After the Do Until I have just a condition to end the flow :

 

s4.PNG

 

After reading around I tried many different combinations for the condition of the Do Until. But here it goes:

1 - Condition: item_exists is not equal to bool(true)
2 - Delay for 3 hours
3 - Set item_exists to bool(false)
4 - Retrieve the item that triggered the flow by ID
5 - Apply to each of the result set from step 4 (should retrieve only 1 item)
5.1 - For the item that is returned (meaning that it exists) I set item_exists to bool(true)

 

So this should work like this:
Once the flow starts, it goes into the Do Until. After waiting for 3 hours, sets the var to false and
runs a get items to check if the sharepoint list item still exists:
- if it exists, the loop should continue to run (item_exists = true, doesn't meet the condition of not equal to true)
- if it doesn't exist, item_exists should remain as false, hence meeting the condition and ending the loop.

 

If the loop is ended, the next condition (if item_exists is equal to bool(true)) will not be met and terminate the flow run.


But this just doesn't work and I really don't know how else to make it work 😕

when the loop starts, it waits for 3 hours and then goes directly into the next step out of the loop.

 

Any help or comments will be really
appreciated.

Thanks !

Juan

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Post Prodigy
Post Prodigy

Re: [Do Until] goes trough the first run on the loop and doesn't work

Hi @juanmsue ,

 

According to your description of the flow demand, and the screenshots of your flow, your problem exists in that you do not judge the existence of item in do-until. You can configure your action according to my screenshot as below.

 

Add a condition to judge the existence of item that created in the beginning.

length(body('Get_items')?['value'])

If the length is not equals to 0, set variable item_exists to false.Annotation 2019-05-06 105440.png

 

Please have a try with them.

 

Best Regards,

Community Support Team _ Lin Tu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Highlighted
Helper III
Helper III

Re: [Do Until] goes trough the first run on the loop and doesn't work

I'm not entirely clear on what you're trying to do here, but I'm guessing Flow is exiting the Do Until... loop after the first cycle because you're setting item_exists to False in one of the actions. Even though you set that variable back to True later on, the Do Until conditions have already been invalidated and the Do Until... loop exits after that first cycle.

 

There is a better way to check if an item exists than what you've implemented here. Basically, you'll still use Get Items, but then you'll evaulate the output of that action in a conditional. That way, you can adapt your Flow so that item_exists won't need to be set to False (ending your Do Until... loop) until the item truly doesn't exist.

Highlighted
Post Prodigy
Post Prodigy

Re: [Do Until] goes trough the first run on the loop and doesn't work

Hi @juanmsue ,

 

According to your description of the flow demand, and the screenshots of your flow, your problem exists in that you do not judge the existence of item in do-until. You can configure your action according to my screenshot as below.

 

Add a condition to judge the existence of item that created in the beginning.

length(body('Get_items')?['value'])

If the length is not equals to 0, set variable item_exists to false.Annotation 2019-05-06 105440.png

 

Please have a try with them.

 

Best Regards,

Community Support Team _ Lin Tu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

firstImage

Join the new Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

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!

Top Kudoed Authors
Users online (11,369)