Skip to main content
Solved

Tracking loop progress in workflows

  • March 9, 2022
  • 3 replies
  • 125 views

christopherlecky
Explorer
Forum|alt.badge.img+16

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. 

If you have a question or comment, please create a topic

3 replies

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

@RMcG may know


Forum|alt.badge.img+6
  • Vaulter
  • 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
Explorer
Forum|alt.badge.img+16

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.