Safe Looping Stuck At Its Own Pause

  • 6 December 2019
  • 9 replies
  • 22 views

Badge +9

My daily site workflow which needs to loop over 1,500 items started yesterday at 2.00pm in the afternoon, and seems to have gotten stuck at 8.32pm. Workflow status remains "In progress".

 

It's now 8.00am and it still hasn't moved. Should the SharePoint Timer Service be restarted? Should I attempt tweaking the workflow to perform a batch loop?

 

This happens approximately 2-3 times out of every 10 schedules. Sometimes it resumes after this long pause. Once in a rare while it randomly errors. Most of the time, it completes without a hitch.

 

5845i0FDC01AA6782F2F5.jpg


9 replies

Userlevel 6
Badge +22
Hi,
I think you should go with your suggestion of batching the looping.
In my experience doing that resolves this issue.
Badge +12

@furstlars .....what's the logic of your workflow, instead of loop, did you explore the possibility of for loop?

Badge +9

@kunalpatel I always use the for each loop. I have nested another loop (which also needs to query/filter a large list) inside the main loop so as you can guess it's a pretty repetitive process.

I ran this site workflow on Friday 6.00pm, this time batch looping the main loop. The workflow ended on Sunday 1.35am with no glitches. The downside here, clearly, is a prolonged workflow duration. Ideally I would like to be able to run this daily. Without batch looping, it normally completes by mid-morning the next day.

 

On the side, the batch loop didn't process 25 items before pausing. I counted anywhere between 8-13. It's an irregular count. Why?

 

I will disable the batch loop and see how it fares tonight.

Badge +9

@kunalpatel I always use the for each loop. I have nested another loop (which also needs to query/filter a large list) inside the main loop so as you can guess it's a pretty repetitive process.


I ran this site workflow on Friday 6.00pm, this time batch looping the main loop. The workflow ended on Sunday 1.35am with no glitches. The downside here, clearly, is a prolonged workflow duration. Ideally I would like to be able to run this daily. Without batch looping, it normally completes by mid-morning the next day.

 

On the side, the batch loop didn't process 25 items before pausing. I counted anywhere between 8-13. It's an irregular count. Why?

 

I will disable the batch loop and see how it fares tonight.

Badge +12

@furstlars ....Will it be possible to share details on query list actions? Which fields you're trying to get and what are the filter parameters?

Badge +9

@kunalpatel the workflow makes list queries 3 times:

 

Query List A, where Field A1 is not null. Store Field A1 into collection (there will be similar values in this collection and a collection operation removes these duplicates)

 

Inside parent loop (for each Field A):

 

Query List A again, filter where Field A1 is equal to the current Field A1

Query List B, get all items, store Fields B1 and B2 into their own collections

 

Nested loop (for each B1)...

Badge +12

@furstlars 

For list A's query....I can't think of any alternate logic but for list B, I don't see any filters when querying it or any dependencies on list A collection value in querying list B. Can't you move it outside parent's loop? This way it won't be querying multiple times (i.e. for each collections value of list A).

 

Also, can your logic work as a list workflow? What if you start a list workflow on your items from a site workflow or put a schedule on your list items? Just a thought !!!

Badge +9

@kunalpatel I would like to figure a way to substitute the 2nd list query in the loop by way of looking at a collection instead.

 

To this end, I need to COUNT the number of items in that collection that is of a SPECIFIC VALUE corresponding to the current value in the loop.

 

For e.g. using a COUNT collection operation: count the number of items that has a value of 75 (where 75 is the current value in the loop). It's exactly for this reason why I'm querying the list at this point.


Any thoughts how this can be done?

 

N.B. - Ran the site workflow manually yesterday at 7:00am with no batch loop this time. It finished today at 12:00pm with no glitches. (it's cross referencing about 2,000 items in List A and 600 items in List B).

Badge +12

@furstlars ....I'm not sure below approach will work or not but can you try it?

 

  • Query all items from list A and all items from list B
  • Get all the fields you need....even the one which needs for filter
  • Now using RegEx and split option, you can store the values in a new collection
  • Using num variable for index and collection operation actions, can you get what you need?

Reply