Resume workflow

A few ways to resume a stucked workflow

Check following cases on how to handle stucked workflows.

Case 1: Workflow is stuck on approvals

In case of any changes in the logic of a process, or in case of a stuck workflow, or for example the approvals were sent to the wrong approvers, it’s always possible to cancel and restart a workflow via script:

var current = new GlideRecord("table_name_the_workflow_runs_for");
current.get("sys_id_of_the_record_for_which_we_Want_to_restart_the_workflow");
var comment = "Comment to be added to the existing approvals that will be set as cancelled";
new WorkflowApprovalUtils().cancelAll(current, comment); 
new Workflow().restartWorkflow(current);

Case 2: Workflow has been cancelled due an error

From the wf_context record, in the related list “Workflow Executing Activities” we need to add the UI action “New”. Selecting configured > list control and uncheck “Omit new button” will do the trick.

Then note the sys_id of the activity in the related list “Workflow Activity History” from which we want to go back to. Go to the workflow context, create a new Workflow executing activities record. As all fields are read-only, disable the UI policy “default read only”. From the activity reference field search for the sys_id you copied before, make sure record is in executing state, and submit then nudge the workflow, or update the record the workflow is running against.

Andre Kosak
ServiceNow Developer, Freelancer

Develop whatever!

comments powered by Disqus

Related