Skip to main content

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.

 

 

 

@RMcG may know


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. 


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.