Loop Questions - VisualCron - Forum

Community forum

Here is a step by step of the job currently:

Step 1 is to hit SQL to figure out what APIs I need to hit.

Step 2 is to hit those APIs with a simple GET. This GET retrieves the current date (json payload) from a management system.
Step 3 parses the JSON in SQL. If the date from the API is earlier than yesterday's date, it will return the date, otherwise it will return "STOP".
Step 4...what I would like is if the output of Step 3 is a date, run an API (PUSH). If the output of Step 3 if "STOP" then go to back to Step 2 and start the next iteration of the loop.
Loop END

For the flow of Step 4 I have a "On Start" event type that says if the value of step 3 = "STOP", then GOTO Step 2. However, it is just stuck in a loop of hitting the same API that says "STOP" over and over again because it isn't going to the next iteration.

Is there something that I am missing?

I believe what's happening here is that since you're going BACK to step 2, it doesn't consider this iteration of the loop to be complete, so it'll just keep repeating it. What I've done in situations like this is use a "Wait" task (which waits for 0 time) - this acts as a placeholder, which can be referenced in the Flow section of other tasks. Try adding this type of task as the ending task of your loop; then, in the flow of step 4, us the "On Start" type (as you've already done) to say "if the value of step 3 is "STOP" then continue with the next task in sequence". The next task would be your "Wait" task. This will cause it NOT to execute your API Push task, and it'll continue with the Wait task, which is the end of the loop. This way, it'll know that it reached the end of this loop iteration and then start back at the beginning of the loop with the next iteration.

Hopefully that helps!
Just to add to my response, you probably don't even need the "Wait" task that I suggested... I just usually add those because I sometimes add other tasks to the job that I move into the loop, so using these Wait tasks means I don't have to constantly update the loop and change the ending task. If you just change your flow in step 4 to say "continue with next task", that'll probably do what you want; it'll skip the current task and realize that that was the last task in the loop, and then go back to the beginning of the loop.
Scroll to Top