From 9e68af2dfc72e0e149d7df9c05f366e1fc899f96 Mon Sep 17 00:00:00 2001 From: lauri457 <55710064+lauri457@users.noreply.github.com> Date: Fri, 10 Oct 2025 16:17:04 +1100 Subject: [PATCH 1/4] Create Execute wf activity by sysid --- .../Execute wf activity by sysid | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Specialized Areas/Fix scripts/Nudge errored workflow/Execute wf activity by sysid diff --git a/Specialized Areas/Fix scripts/Nudge errored workflow/Execute wf activity by sysid b/Specialized Areas/Fix scripts/Nudge errored workflow/Execute wf activity by sysid new file mode 100644 index 0000000000..24c422b114 --- /dev/null +++ b/Specialized Areas/Fix scripts/Nudge errored workflow/Execute wf activity by sysid @@ -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) From 7ffee8f9e0f85b8139b502db4caf34b021b983bc Mon Sep 17 00:00:00 2001 From: lauri457 <55710064+lauri457@users.noreply.github.com> Date: Fri, 10 Oct 2025 16:18:33 +1100 Subject: [PATCH 2/4] Create README.md --- .../Fix scripts/Nudge errored workflow/README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 Specialized Areas/Fix scripts/Nudge errored workflow/README.md diff --git a/Specialized Areas/Fix scripts/Nudge errored workflow/README.md b/Specialized Areas/Fix scripts/Nudge errored workflow/README.md new file mode 100644 index 0000000000..484f33f176 --- /dev/null +++ b/Specialized Areas/Fix scripts/Nudge errored workflow/README.md @@ -0,0 +1,12 @@ +# 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. From 248459b585c43af61aa9b092e1dc5ace80d627b6 Mon Sep 17 00:00:00 2001 From: lauri457 <55710064+lauri457@users.noreply.github.com> Date: Fri, 10 Oct 2025 16:18:56 +1100 Subject: [PATCH 3/4] Rename Execute wf activity by sysid to Execute wf activity by sysid.js --- ...ecute wf activity by sysid => Execute wf activity by sysid.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Specialized Areas/Fix scripts/Nudge errored workflow/{Execute wf activity by sysid => Execute wf activity by sysid.js} (100%) diff --git a/Specialized Areas/Fix scripts/Nudge errored workflow/Execute wf activity by sysid b/Specialized Areas/Fix scripts/Nudge errored workflow/Execute wf activity by sysid.js similarity index 100% rename from Specialized Areas/Fix scripts/Nudge errored workflow/Execute wf activity by sysid rename to Specialized Areas/Fix scripts/Nudge errored workflow/Execute wf activity by sysid.js From 27a481a6180ed98659563e49fb2210a61629f7a4 Mon Sep 17 00:00:00 2001 From: lauri457 <55710064+lauri457@users.noreply.github.com> Date: Fri, 10 Oct 2025 16:21:19 +1100 Subject: [PATCH 4/4] Update README.md --- .../Fix scripts/Nudge errored workflow/README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Specialized Areas/Fix scripts/Nudge errored workflow/README.md b/Specialized Areas/Fix scripts/Nudge errored workflow/README.md index 484f33f176..cc5dcc538d 100644 --- a/Specialized Areas/Fix scripts/Nudge errored workflow/README.md +++ b/Specialized Areas/Fix scripts/Nudge errored workflow/README.md @@ -2,7 +2,7 @@ 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 +## Purpose Workflows in ServiceNow can occasionally get stuck due to: - Misconfigured transitions @@ -10,3 +10,8 @@ Workflows in ServiceNow can occasionally get stuck due to: - 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) +