How to reset For Each loop

 2 Replies
 0 Subscribed to this topic
 52 Subscribed to this forum
Sort:
Author
Messages
JasonP
Advanced Member
Posts: 28
Advanced Member

    Im using a For Each loop to loop through an array which contains a list of strings that looks like this COMPANYNO|DATE.  When my outer SQL1 company equals Company from Data Iterator (which is being used to split the string), I want to exit the For Each loop.  When I exit the For Each Loop, it never really ends or resets.  

     

    On the second iteration of SQL1, we go back into the For Each loop and I want to start back over at the beginning of the array with iteration 1. However when it comes back in on the second pass, the For Each loop picks up with the iteration it left off.

    I would like to Reset the For each every time I come in but my assign node isn't working, is this even possible, thanks in advance, see attached.

     

    I'm to reset it ForEach7740_iterationNumber = -1, Ive also tried setting to zero and 1 and doesn't seem to work.

     

    Attachments
    Jeff Shumate
    Advanced Member
    Posts: 31
    Advanced Member
      I ended up using the "expression" type rather than the Iteration type. It resets the count each time is starts the loop again. So Initial expression: I=1
      Expression: I<10
      Post Expression: I++
      You should still be able to stop the loop the same way you do now.

      Or are you using another loop type?
      JasonP
      Advanced Member
      Posts: 28
      Advanced Member

        Yeah im looping through a javascript Array opposed to Expression.  I could count the array and do it your way.  It would probably automatically reset itself that way if I exit for each and come back in.  thanks for the tip, ill try it.