cancel
Showing results for 
Search instead for 
Did you mean: 
andreapasutti
Nintex Newbie

For Each Loop Loops Too Many Times

Jump to solution

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.

0 Kudos
Reply
3 Replies
Highlighted
Nintex Employee
Nintex Employee

Re: For Each Loop Loops Too Many Times

Jump to solution

‌ - 

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!

View solution in original post

Reply
andreapasutti
Nintex Newbie

Re: For Each Loop Loops Too Many Times

Jump to solution

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

Reply
Nintex Employee
Nintex Employee

Re: For Each Loop Loops Too Many Times

Jump to solution

Happy to help!

Reply