Microsoft Flow – Mystery of Do Until loop

Building solutions based of Microsoft Flow some times remind me of orchestration products.

If you follow the logical approach you can do wonders and automate many things using Microsoft flow.

This week I was working with one of the flow automation where I had a need to use DO UNTIL loop but  I was not successful unless number of tries and research on internet so want to share the learning on how to make DO Until to work correctly.

Few things to make DO UNTIL to work.

  • Do not use Blank value
  • Status is equal to CheckPassed means that until the value gets equal to Check passed keep on Running.(This is where many users on the Internet got stuck as DO UNTIL was not working because they were just setting the Status value in the list to the value they have defined in the loop statement where as its other way round that it should not equal to that value to make it running)
  • Add delay as per your requirement.
  • Get-item is used to refresh list value from SharePoint.(i.e. get new value) — This is the second important point to always use refreshed value
  • Status that is used in DO UNTIL should be from Get-item that you have added in DO UNTIL function. — This is the last important point to take care of.

There are other things to take care with this loop:

  • By default DO UNTIL iterations are 60 and time out is 1 hr.
  • You can change that by clicking Change limits.

  • Count can be changed to max 5000 iterations.
  • You can change the PT1H to PT24H i.e. 24 hrs or PT72H means 72 hrs.

 

If you follow this approach than your DO UNTIL loop will work correctly.

 

Thank You for reading

Sukhija Vikas

http://SysCloudPro.com

PowerShell Fast Track

Advertisement

22 thoughts on “Microsoft Flow – Mystery of Do Until loop

  1. Hi Vikas,
    Thanks for sharing this. I am trying to implement the solution but getting it wrong somewhere. I have used email before and after do until and I do a one minute pause in Do until. Get items is on the same library.
    I am not able to share a screen shot with, let me know if I can share the screen shot to let you know the exact configuration of the Flow.
    Thanks in advance for the help.

      • My DoUntil starts with checking for a variable ‘x’ status. Once the status is changed from 0 to 1 the DoUntil should stop. I can’t use GetItem since it utilize sharepoint while mine compares with variable created inside the Flow.

        any ideas?

  2. Pingback: Microsoft Flow – Mystery of Do Until loop | Cloud Computers Guide

  3. Do you have any information on Do until’s failue behaviour? My Flow timed out (over 30 days) and the do until started sending approvals on a loop, a thousand approval requests were sent to the same user. My Flow limit is set as (blank) for iterations and PT720H for tiemout duration.

  4. Hi Vikas

    I am using Do until to send approvals.
    I am using tow variables
    1 – approvercount which is initialized to 1.
    2 – The second variable for total approvers.

    I have do until loop with condition set as approvercount is less that equal total approvers. I am incrementing approvercount by one with in the loop.

    The flow runs but only one time and stops even if the value of approvercount is less than total approvers.

    Any thought ? I will be happy to share a flow if you let me know where n how can I share it.

    – Milind

      • No sure what you mean by recount. I am not updating any values outside of the flow.

        I dont see an ability to load pictures of flow here.. how can I get them to you ( Email / Webex / Google Drive / One Drive ) ? In mean time here are detail step of the flow ..

        I am using solution in Power Automate so I can use child flow for dynamic approvals.

        Master Flow Details –

        1 : Powerapps – I am calling the flow from the button in PoweeApps and passing the names of approvers in comma separated string

        2 : aprString – Variable 1 initialized to the string of approver names passed from powerapps

        3 : aprArray – Variable 2 initialized to the array of approvers by using slit on the aprString

        4 : aprCount – Variable 3 integer initialized to 1

        5 : aprCurrent – Name of current approver initialized to 1st approver from the aprArray

        6 : Do Until aprCount is less than equal to 4 ( I had set it to number of elements in aprArray but that did not work so I changed it to fix number to see if the loop will run. )

        7 : In do until – Call the child the flow

        8 : In do until – ncrement aprCount by one.

        End of the flow.

        Child Flow Details

        1 : Manually trigger the flow from parent flow.

        2 : Create an approval with approver, subject, message body and link passed from the parent flow call

        3 : Wait for approval

        4 : Pass the value back to Parent flow

        End of the flow.

        Hope this helps. please let me know if you need more details.

  5. How do I use Do until loop if I have to send the reminder every 14 days. In that case I could send max 2 reminders. I see the timeout or limit is 30 days max. Or is it my understand is wrong?

  6. Pingback: How to – Use Do until and Delay in Power Automate – Nishant Rana's Weblog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s