Skip to content

Commit 9e68af2

Browse files
authored
Create Execute wf activity by sysid
1 parent 695d030 commit 9e68af2

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* dirty fix to make workflow execute at wanted activity after error or wrong path for example
3+
* run as fix script or in bg.
4+
*/
5+
var wfContextId = "ca1ba1bc83e83210557ff0d6feaad37d",
6+
wfActivityId = "b18321f083e83210557ff0d6feaad39d";
7+
8+
(function (wfContextId, wfActivityId) {
9+
//check valid context sysid
10+
var contextToFix = new GlideRecord("wf_context")
11+
if (!contextToFix.get(wfContextId)) {
12+
return null;
13+
}
14+
//set context state as executing
15+
if (contextToFix.getValue("state") != "executing") {
16+
contextToFix.setValue('state', 'executing');
17+
contextToFix.update();
18+
}
19+
//create instance of activity [wf_activity] to execute
20+
var activityToContinueFromGr = new GlideRecord("wf_executing");
21+
activityToContinueFromGr.newRecord();
22+
activityToContinueFromGr.setValue("context", wfContextId);
23+
activityToContinueFromGr.setValue("activity", wfActivityId);
24+
activityToContinueFromGr.setValue("state", "executing");
25+
activityToContinueFromGr.insert();
26+
27+
//send the update event to make the executing activity run
28+
new Workflow().broadcastEvent(wfContextId, 'update');
29+
})(wfContextId, wfActivityId)

0 commit comments

Comments
 (0)