Start stalled workflows from beginning

When workflows stall, they get stuck on the stage that caused the issue. Many times over it is useful to start the workflow from the start – a complete re-run.
But there is no way to do that in the UI – you can only unstall the workflow to start execution from the same stage. And that is not very useful.

Today I had to deal with a bunch of stalled workflows that had stalled stage removed (don’t ask me why – reasons!). And I did not fancy re-triggering these manually – these had to be done, otherwise I’d be loosing data. Long story short, here is a bit of SQL that will cause your stalled workflows to start from the first stage, not from the place where they got stuck:

update [dbo].[OC_WORKFLOWINSTANCESTACK]
set STAGEID = w.STARTSTAGE
from [dbo].[OC_WORKFLOWINSTANCES] wi
inner join [dbo].[OC_WORKFLOWINSTANCESTACK] s on s.INSTANCEID = wi.INSTANCEID
inner join dbo.OC_WORKFLOWS w on w.WORKFLOWID = wi.INITIALWORKFLOWID
where stalled = 1
and TRIGGERNAME='My failed trigger'

This entry was posted in Uncategorized and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *