Help Me Loop Through Each List Item That Has A Repeating Section

  • 16 January 2018
  • 8 replies
  • 6 views

Badge +9

I have been able to successfully loop through the XML in the repeating section; what I need to do now is to run a site workflow every day that loops through each list item to check's Today's Date against the Activity Due Dates and send emails accordingly.

My one and only problem here is trying to get the workflow to loop through each list item. At the moment it only picks up the first item in the list. Help! Am I looking at nesting the existing repeating section loop inside a List Item loop? Some workflow samples would be appreciated.

212186_pastedImage_2.png


8 replies

Userlevel 5
Badge +14

have a look on this thread, there I guided to resolve the same problem

 

Badge +9

So having now put an outer loop the site workflow appears to be looping through each list item, but keeps getting the same repeating section from the first list item?

The outer loop itself is used in the form workflow and works perfectly so I don't see why any action should be changed in the inner loop.

Outer for each:

212226_pastedImage_1.png

Inner for each:

212227_pastedImage_2.png

212225_pastedImage_1.png

212228_pastedImage_3.png

Userlevel 5
Badge +14

but keeps getting the same repeating section from the first list item?

how do you populate ResponsibleBUCollection?  in a query before loops?

with every iteration of outer loop you start over loop for ResponsibleBUCollection collection. since the ResponsibleBUCollection seems to be populated before loops you still work with the same content.

you should:

1. start an outer loop (to iterate through items)

2. within the loop, convert repeating section of current item (identified by outer loop index) into (set of) collection(s).

3. start an inner loop over (one of) collection populated in step 2.

Badge +9

These are the actions used prior to the outer loop:

212256_pastedImage_1.png

1. The Query list action retrieves the following fields. Note that the WorkActivities field is basically a multiple lines of text field type used to to hold the repeating XML for ResponsibleBU, ActivityDueDate, WorkActivity, and Completion Date. These are the fields needed for the inner loop.

212257_pastedImage_2.png

2. I then query WorkActivities to extract the 4 repeating fields and store them in separate collections.

212258_pastedImage_3.png

I did what you suggested, but still can't get it to get the repeating data in the next list item. I'm thinking that the logic may not be correct in the inner loop's for each, but what collection should then I be targetting for the repeating section, if ResponsibleBU isn't correct? Repeating sections don't have ID's themselves.

This same inner loop is used in the Form Workflow - without the outer loop of course (note this is a site workflow) and already works perfectly as it is.

212262_pastedImage_1.png

REVISED WORKFLOW:

Userlevel 5
Badge +14

so does revised workflow work or not?

btw, do not increment loop index variable on your own, for each loop action takes care of its incrementing...

Badge +9

I finally figured it out!

The data that wasn't part of the repeating section - I had failed to put them in collections. So in essence I was always dealing with the data in the first list item even though the outer loop was moving on to the next list item.

I believe I need to increment both outer and inner loop indexes because the collection operations require an index.

I will post a screenshot of the working workflow when I'm back next week.

Badge +9

Log in history list showing the 2 list items and their corresponding outer and inner loops:

Badge +9

This site workflow works 100% and will run once a day to check all list items and their associated activity due dates captured as repeating section data.

If any work activity due dates are found to be meet the specified criteria, it'll send out email reminders.

Reply