Activate a stuck workflow which “hangs” on activity timer

General Add comments
by:

In some situations it might occur that a workflow gets stuck. This is the case if the workflow is waiting for an action (or condition) that will never take place. Unfortunately there isn’t one generic solution for this as it could have been caused by several situations and with different workflow activities.
That’s why it can be quite painful to solve this kind of issues. However, there is some good news if the workflow “hangs” on an activity timer!

Read on, read on…..

Workflow timer activities are calculated and after that scheduled as a scheduled job. They are waiting to receive a trigger at a specific time so the workflow can “jump” to the next activity.
On our supportdesk we sometimes see that the scheduled jobs (which should perform the trigger action) are not available (anymore).

So in fact these workflows will wait forever!

Fortunately it isn’t that hard to start the workflow in these situations. What we need to do is create a new scheduled job for it, so the activity will be triggered again.

Let’s use an example of a change record that has a “stuck” timer activity in the workflow.

First we should find the sys_id of the stuck timer activity.
1. Copy the sys_id of the record ( sys_id of the change record in this case)

2. Go to Workflow context (All context module) and search for “ID” = “<sys_id step 1>”

3. Open the workflow context which is found

4. Now go to the executing activity that is stuck

5. Copy the sys_id of this stucked activity (in this case : 9de8b89e7b63100050e914aa3f4d4d34)

To be sure this activity is really stuck, you can check if there isn’t a scheduled job planned for this.
To do this, go to the scheduled jobs (in System scheduler application) and search for “document key” = “<sys_id step 5>”.
At this time we expect to not find any records here.

Finally, we create a new scheduled item that should run once:

6. Go to the “Scheduled jobs” (in the system scheduler application)

7. Click on the New button

8. First make the following two fields visible on the form (via Personalize à Form Layout):
Document” and “Document key” and save the form. This is needed as we need to fill in some Information in these two fields.

9. Now populate the following fields in the schedule item (see picture below):

– Name:            WFTimer<sys_id step5>
– Next action:    Fill in time for execution of the job
– Script:            var w = new Workflow(); w.fireEvent(current, ‘timer’);
– Trigger type:    run once
– Document:       wf_executing
– Document key:  <sys_id step5>

10. Finally, Submit the schedule item.

At the time specified in the next action field the activity will be triggered again.
If you did it correctly the workflow is activated again!

Please let me know if you may have any questions related to this.
You can reach me via email (ben.hankel@2e2.nl) or by leaving a comment on this post.

One Response to “Activate a stuck workflow which “hangs” on activity timer”

  1. Will Powers Says:

    Hi Ben-

    Regarding Stuck workflows, do you have a better solution than https://community.servicenow.com/community?id=community_article&sys_id=cb6caea1dbd0dbc01dcaf3231f961937

Leave a Reply