Skip to main content
Nintex Community Menu Bar

For Each Loop Loops Too Many Times

  • December 11, 2017
  • 3 replies
  • 7 views

Forum|alt.badge.img+7

I have a list of all the sites in our site collection. For each site, the members and owners are populated. I add each member and owner to their own collection variables, then I loop through the collection variable to get their display name and add them to a list via build string. This list will go in the body of the notification so the recipient can know who all the owners and members of their site are without having to navigate there.

Once all the owners and members have been added to the collection, we evaluate and remove based on certain criteria (not a valid employee in AD, a VIP, etc.). In my latest test, I have removed 3 owners and 2 members. The problem is that the loop will continue 3 more times and add the last person's name to the list each time. It appears to be adding extra semicolons at the end. This does not coincide with any owners or members I have removed from the list (removed 2 members, added 3 semicolons). I have a commit pending changes after each build string in the loop. What is going on? I've used For Each loops to do this very logic in other workflows and this hasn't happened.

3 replies

jesse_mchargue
Forum|alt.badge.img+12

‌ - 

Are you reusing the same collection variables for each site? If so, are you ensuring that they are empty? 

I have done something similar and had to ultimately clear the collection and reset my index back to [0].

Hope this helps!


Forum|alt.badge.img+7

Thank you for that insight. I had to clear not one, but two variables in order to get my list. Thank you!! laugh.png


jesse_mchargue
Forum|alt.badge.img+12

Happy to help!