cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Nested "For each"

Jump to solution

I have a need to query multiple columns from a list, could I declare multiple collection varialble and add these values to the collections?

After adding values to the collection variables, I want to use nested for each loop so in the outer most loop I have the Unique identifier for which I can lookup other related values within the other collections.

For each (ID) - Step A

     For each look up ORG where ID = ID from step A

          For each look up employee where ID = ID form step A

               do something in the list

          next

          do something in the list

     next

     do nothing this is the master record for keeping unique ID available to other loops

next

Is this correct?

Thanks in advance.

-DT

Labels: (1)
0 Kudos
Reply
42 Replies
Automation Master
Automation Master

Re: Nested "For each"

Jump to solution

yes, you definitely can query multiple columns, and store each of them to a separate collection.

but I think you do not need to nest loops at all.

once you populate multiple collections within one query, you are guaranteed all the collection will have just the same number of elements, and as well that at certain index position across collections there are value from the same item.

so what you need to do is to choose one of collections as driving one and iterate through it.

within for each action save current index into workflow variable.

the use this variable to get data from other collections.

Reply
Nintex Employee
Nintex Employee

Re: Nested "For each"

Jump to solution

What Marian said is definitely correct. I've done something similar here http://www.vadimtabakman.com/nintex-workflow-iterate-through-related-collections.aspx

Reply
Not applicable

Re: Nested "For each"

Jump to solution

Thank you let me try it and will let you know how that goes.

Reply
Not applicable

Re: Nested "For each"

Jump to solution

Thanks I will try and let you know.

Reply
Not applicable

Re: Nested "For each"

Jump to solution

Looking forward to your follow up. Good luck!

0 Kudos
Reply
Not applicable

Re: Nested "For each"

Jump to solution

Hello Frank,

I am trying to pull all the ITEM ids into a collection and then access them during the for each loop with the help of index variable and then store ID into a variable of List ID type. However in an attempt to update the particular list item using the above mentioned variable, it is found to be blank and so the workflow is unable to update the list item.

Step A - collect all the ID store into collection

Step B - collection step - get list ID from the collection and store into a variable of List id data type. 

Step C - Update the list where ID = variable (workflow fails)

Should the variable be a number / integer type?

Reply
Not applicable

Re: Nested "For each"

Jump to solution

SWF.JPG

Reply
Not applicable

Re: Nested "For each"

Jump to solution

This update fails.

SWFUI.JPG

Reply
Not applicable

Re: Nested "For each"

Jump to solution

D T​, you don't want my workflow advice, I just manage the community and wanted to know if the thread was coming to a close. Hopefully the community will get you to a solution. :-)

Reply