Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Using "Do the following in parallel" into a loop "do the following until"

CKJ-BeOS
Tera Contributor

Hi,

 

I try to do a loo where i want to execute one action if a sc_task is updated OR if 2 minutes is passed

but repeat 5 times.

When le loop is executed one time and passed on one branch of the "do the following in parallel" it not wait a second time in the branch where the wait.

I think when used a "Do the following in parallel" it's only execute one time the branch, not execute a second time.

But need to find solution to loop until a task is updated or 2 minutes passed and execute the "wait 2 minutes" only 5 times.

 

Regards,

Cédric

7 REPLIES 7

Ankur Bawiskar
Tera Patron
Tera Patron

@CKJ-BeOS

Do in Parallel won't work here -> it branches simultaneously and does not repeat the same branch multiple times within a loop 

My thoughts

  • Set up a loop that runs until a counter reaches 5 (or until your condition is met) (use flow variable)
  • Inside the loop, use a "Wait for condition" action to check if the sc_task is updated. (use some field change to see if update happened)
  • If the task is not updated, use a "Wait for duration" action to wait 2 minutes.
  • Increment a counter variable after each iteration.

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

I think the solution not what i need, i need that in parallel the user can update the task or wait 2 minutes 5 times the two things can run the action (a call of external API rest)

In fact i need that after the API call if the result is in error we want to try 5 next times but in parallel the user must be execute the rest API call if he use a ui action in task that update the task.

after the 5 times executions, the user can only use the ui action to call next time the rest API call.

The loop can be close only if the sc_task is closed by user.

@CKJ-BeOS 

sorry very difficult to understand.

Could you phrase your question and business requirement properly so that better approach can be given?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar ,

I try to explain :

I need to wait in parallel two things :

- wait 2 minutes (maximum 5 times) -> execute "action"

- wait sc_task is updated -> execute "action"

exit if the result of the "action" is good or if the user close the sc_task

the action is the same, a REST API Call that return a result

it is more comprehensible ?

Sorry for my bad previous explain.