cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
juanmsue
Level: Power Up

[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:

 

s1.PNGI 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
v-lin-msft
Level 10

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.

2 REPLIES 2
jake
Level: Powered On

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.

v-lin-msft
Level 10

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.

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020.

thirdimage

Flow Community User Group Member Badge

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

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 Flow Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 429 members 5,429 guests
Please welcome our newest community members: