Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* dirty fix to make workflow execute at wanted activity after error or wrong path for example
* run as fix script or in bg.
*/
var wfContextId = "ca1ba1bc83e83210557ff0d6feaad37d",
wfActivityId = "b18321f083e83210557ff0d6feaad39d";

(function (wfContextId, wfActivityId) {
//check valid context sysid
var contextToFix = new GlideRecord("wf_context")
if (!contextToFix.get(wfContextId)) {
return null;
}
//set context state as executing
if (contextToFix.getValue("state") != "executing") {
contextToFix.setValue('state', 'executing');
contextToFix.update();
}
//create instance of activity [wf_activity] to execute
var activityToContinueFromGr = new GlideRecord("wf_executing");
activityToContinueFromGr.newRecord();
activityToContinueFromGr.setValue("context", wfContextId);
activityToContinueFromGr.setValue("activity", wfActivityId);
activityToContinueFromGr.setValue("state", "executing");
activityToContinueFromGr.insert();

//send the update event to make the executing activity run
new Workflow().broadcastEvent(wfContextId, 'update');
})(wfContextId, wfActivityId)
17 changes: 17 additions & 0 deletions Specialized Areas/Fix scripts/Nudge errored workflow/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Workflow recovery script

This script provides a quick and dirty fix for resuming a stuck or misrouted workflow in ServiceNow. It manually forces a workflow context to resume execution from a specified activity, bypassing errors or incorrect transitions.

## Purpose

Workflows in ServiceNow can occasionally get stuck due to:
- Misconfigured transitions
- Script errors
- Unexpected data conditions

This script allows you to manually resume execution from a desired activity within a workflow context.

## How to

Change the value of the variables in the script to the [wf_context] sys_id (wfContextId) and the [wf_activity] sys_id (wfActivityId)

Loading