I have a workflow which have a loop action and the loop runs from 0-15 times depending on the conditions. But loop action takes a lot of time for each repetition. Is there any way by which I can speed up this pause between loops or any other way by which I could attain my goal?
Solved! Go to Solution.
as Barry said, you could disable safe looping but remember that the changes to Safe Looping setting in Central Administration are reflected only to the workflows published after the change, so if you prefer to disable safe looping only for one or few workflows, you could disable it, publish them, and then re-enable safe looping..
You have just to remember that each time you publish a workflow, the current setting is applied to it
One "trick" is this: Go to Central Admin, and disable safe looping (in global settings). Open your workflow in designer, and publish the workflow when safe looping is off. Go back to Safe Looping in central admin, and re-activate it. This will create an exception for the workflow you published, but leave Safe Looping on for the rest of the farm. If you modify your workflow, you will need to follow the same process each time you publish.
However, if that workflow is resource intensive, it could have performance implications for the farm so I would recommend you test it thoroughly prior to going live with it.
there is another, semi-fast way where you can keep safe looping enabled and still have a relatively fast loop. This way uses the for each action, which does not have the same safe looping as the loop action.
This way, for each (safe) loop, you can have 20 fast iterations. If you are absolutely sure you wont need more than 20 iterations, you can even forego the for each.
I hope this was readable, if you have any question, please dont hesitate to ask
I've done similar things to this in the past. Great response here!!!
Just out of curiosity, what do you use the Loop action in this case for?
Why not just have to the RegEx and then a For Each.
the Loop action is in case you need more than 20 iterations to reach the desired result. The loop can be removed in case it is absolutely certain there are no more than the predefined number of iterations. By keeping the loop areound the for each, the workflow still can run as long as needed in case more iterations are required.
We do something similar, but your way may be more efficient.
Our collection goes into a For Each with however many items in it, and each time thethe loop runs it adds one to our variable, when the variable hit 10 or so (depending on the workload in the loop) we have a Run If at the end of the loop that runs when our variable hits 10 and then "Pause For" 1 minute. This can actually take up to 5 mins depending on when the timer job runs next, and then it resets the variable back to 0 and continues for the next cycle.
We found that if the For Each loop is running on a large collection it tends to fall over itself. For example, we may have a site workflow that runs on a list to kick off another list workflow on all the items in a list that match certain criteria, this could be hundreds or thousands. It would start off ok, but would soon fall over itself and Stop although it would tell us it completed.
Putting this Pause in the loop enables us to set this process going overnight without worrying about monitoring it.
Whether it's good practice or not, I don't know but it's the best way we found of running workflows on a large number of items.