# How do I write a Do ... Until loop with exit condition

**URL:** <https://community.make.com/t/how-do-i-write-a-do-until-loop-with-exit-condition/37869>\
**Category:** Questions\
**Tags:** functions\
**Created:** [May 17, 2024, 8:57pm UTC](https://community.make.com/t/how-do-i-write-a-do-until-loop-with-exit-condition/37869 "2024-05-17T20:57:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![kamlesh.patel](https://avatars.discourse-cdn.com/v4/letter/k/fbc32d/32.png) [@kamlesh.patel](https://community.make.com/u/kamlesh.patel)\
**Post date:** [May 17, 2024, 8:57pm UTC](https://community.make.com/t/how-do-i-write-a-do-until-loop-with-exit-condition/37869/1 "2024-05-17T20:57:28Z")

</div>

I am looking to call an external api endpoint that process the result. If the response does not meet a condition then I want to sleep for 10 seconds and attempt it again and again until the response meets a condition then exit the loop.

Repeater loop is a fixed loop. I used it to create a prototype scenario. However, I don’t know how to force exit a Repeater loop or if that is even possible.

Any idea?

---

<div class="post-metadata">

**Author:** ![alex.newpath](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/alex.newpath/32/84_2.png) [@alex.newpath](https://community.make.com/u/alex.newpath)\
**Post date:** [May 17, 2024, 9:11pm UTC](https://community.make.com/t/how-do-i-write-a-do-until-loop-with-exit-condition/37869/3 "2024-05-17T21:11:48Z")

</div>

There is no functionality to run a scenario indefinitely. It has a 40 minute max execution limit so you cannot do this in make.

What you can do is schedule it to run to check the status of your system but it can be scheduled once every 15 minutes not every 10 seconds.

Maybe a web hook would be a better way to monitor the state of your system?

---

<div class="post-metadata">

**Author:** ![kamlesh.patel](https://avatars.discourse-cdn.com/v4/letter/k/fbc32d/32.png) [@kamlesh.patel](https://community.make.com/u/kamlesh.patel)\
**Post date:** [May 17, 2024, 9:30pm UTC](https://community.make.com/t/how-do-i-write-a-do-until-loop-with-exit-condition/37869/4 "2024-05-17T21:30:51Z")

</div>

My loop would not run more than 300 seconds total. So 40 minutes max scenario is not an issue.  
I required repeated checks every 10 seconds to see if data is present. Endpoint I am calling is going to return me data but requires few attempts.  
Alternately…  
Is there a way to break out of the repeater loop???  
Is there a way to use the router and filter to return response and break out to the Scenario?

---

<div class="post-metadata">

**Author:** ![samliew](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/samliew/32/13327_2.png) [@samliew](https://community.make.com/u/samliew)\
**Post date:** [May 17, 2024, 9:55pm UTC](https://community.make.com/t/how-do-i-write-a-do-until-loop-with-exit-condition/37869/5 "2024-05-17T21:55:04Z")

</div>

Welcome to the Make community!

This has been asked several times before.

The only method closest to a **do-while** loop in programming in a Make scenario is a **repeater-error**.

For more information, **see**

- [Google Drive - Search for Files/Folders - search all subfolders - #5 by samliew](https://community.make.com/t/google-drive-search-for-files-folders-search-all-subfolders/35523/5)
- [I dont know how to use webhook to get update - #2 by samliew](https://community.make.com/t/i-dont-know-how-to-use-webhook-to-get-update/25833/2)
- [Why is Polling at make.com is so damn hard? - #4 by samliew](https://community.make.com/t/why-is-polling-at-make-com-is-so-damn-hard/33669/4)
- [How can I exit a repeater and continue the flow of a scenario? - #2 by samliew](https://community.make.com/t/how-can-i-exit-a-repeater-and-continue-the-flow-of-a-scenario/16849/2)
- [How can I create a while loop in make?](https://community.make.com/t/how-can-i-create-a-while-loop-in-make/32968)
- [How do I write a Do ... Until loop with exit condition](https://community.make.com/t/how-do-i-write-a-do-until-loop-with-exit-condition/37869)
- etc.

[samliew](https://samliew.com/services) – [request private consultation](https://samliew.com/request-quote?ServiceType=Automation%20Consultation&Referrer=Make)

> Join the unofficial [Make Discord server](https://samliew.com/make-discord-invite) to chat with us!

---

<div class="post-metadata">

**Author:** ![alex.newpath](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/alex.newpath/32/84_2.png) [@alex.newpath](https://community.make.com/u/alex.newpath)\
**Post date:** [May 18, 2024, 2:49pm UTC](https://community.make.com/t/how-do-i-write-a-do-until-loop-with-exit-condition/37869/6 "2024-05-18T14:49:42Z")

</div>

This response could be of interest it uses the error handler and a repeater

> [@Why is Polling at make.com is so damn hard?](https://community.make.com/t/why-is-polling-at-make-com-is-so-damn-hard/33669/4):
>
> Something like this perhaps, you throw an error to break out of the check loop if there is a successful state. Throw error by using null in a required field. [Screenshot\_2024-04-14\_000448] This is where the commit directive comes in useful.

---

<div class="post-metadata">

**Author:** ![Make\_Bot](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/make_bot/32/14661_2.png) [@Make\_Bot](https://community.make.com/u/Make_Bot)\
**Post date:** [August 16, 2024, 3:04pm UTC](https://community.make.com/t/how-do-i-write-a-do-until-loop-with-exit-condition/37869/7 "2024-08-16T15:04:03Z")

</div>


