Skip to main content

I have a workflow on a list, using State Machine. I have a Query List over an External Content Type list, then a For Each loop that processes 233 items, copying them to two other lists. Understandably that takes some time to process. For some reason the workflow repeats the Query/ForEach before the first iteration has completed (like a race car lapping itself on a circuit). So I end up with repeated items in the two destination lists, and the workflow appears to be in a loop (SafeLooping is enabled, BTW). The workflow says "Completed" (and the time is being updated every minute), but that's not true! I had to stop the Timer service to kill it.

 

This is quite critical for my project, so any help pointers would be hugely appreciated!

Paul

Hi Paul Vernon ,

Even with Safelooping enabled, you need to check the frequency of the timer service. If it is 1 minute, then you have only 1 minute of gap between the loops, which ideally should be enough to process the create item but in your case may be causing issues.

You also mentioned, that your workflow repeats the Query function which is outside the For-Each, i assume. This would happen only if the workflow is called over and over again. Check the condiition which executes the workflow.

If these does not resolve the issue, paste the screen shot of your workflow.


Hi Kapil

Thanks for your response.

Timer service frequency is 5 minutes.

Query List lies outside the For Each loop (see screen shot).

The workflow is user-initiated (linked from an Edit Control Block menu), but I know from Workflow history it was only initiated once (and the I confirmed with the user too).

The workflow is quite large, and I have minimized Action Sets to make it fit. The problem lies within the Copy Items state.

CreateComposerSiteCollection.png

Thanks

Paul


Hi Paul,

Use Run Now on Query list and see if your action is not pulling duplicate ID's or data. If it is, then that might be the reason.

Also, add Commit Pending changes action after each Create action. Let us know.


There were no duplicates in the data. However I think putting a Commit Pending Changes after each Create might have fixed the problem. I need to run it a few more times to be sure, and then if it has fixed it, I'll click Correct Answer for you.

Many thanks for your help

Paul


Paul,


You must either Change State or Exit the State Machine at the end of your State Branch, otherwise the State Machine itself will indeed act like a loop and do exactly like you described.   I can't tell by your screen shot whether or not you are changing state/ending state at the bottom of the branch that contains the For Each. 

Thanks


Hi Mike

Every State branch does have end with a Change State or Exit State Machine, including the one you can't see in the screen grab. But thanks for the advice.

It seems that the suggestion of putting in Commit Pending Changes after each Create has fixed the problem, as I'm now unable to replicate the error, and I've pushed it pretty hard. I'm marking Kapil Joshi's as Correct Answer.

Thanks

Paul


Sounds good, just wanted to make sure! grin.png


Reply