Skip to main content
Solved

Tracking loop progress in workflows


christopherlecky
Byte
Forum|alt.badge.img+17

Is there any way to get the loop index and counter in any of the for loop activities?

I have been setting a counter variable prior to the loop starting and incrementing it at the end of every loop, but surely this already exists. 

 

Also I get wonky results when I allow loops to run multiple processes at once.

 

 

 

Best answer by RMcG

To fetch the current index you can use workflow.getParent().getLoopIndex() in a script activity inside the for loop. Will also work in the onstart and oncomplete scripts on other activities inside the for loop etc. 

View original
Did this answer your question?
If you have a question or comment, please create a topic

3 replies

Damian Andre
Vaulter
Forum|alt.badge.img+23

@RMcG may know


Forum|alt.badge.img+6
  • Vaulter
  • 30 replies
  • Answer
  • March 10, 2022

To fetch the current index you can use workflow.getParent().getLoopIndex() in a script activity inside the for loop. Will also work in the onstart and oncomplete scripts on other activities inside the for loop etc. 


christopherlecky
Byte
Forum|alt.badge.img+17
RMcG wrote:

To fetch the current index you can use workflow.getParent().getLoopIndex() in a script activity inside the for loop. Will also work in the onstart and oncomplete scripts on other activities inside the for loop etc. 

Excellent. 

Safe to assume this of the same for all the for loop? foreachjson? for example?

Thanks.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings