How cancel a Playbook (sys_pd_context) via script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2023 10:54 AM
Hello,
Needing to cancel a Playbook (sys_pd_context) via script. Does anyone know the command or call to do so? Also, not sure if canceling the parent will cancel or close out all the child Activity Executions (sys_pd_activity_context). I found this script but determined it only works for Flow Designer, not Playbooks/Process Automation Designer.
var now_GR = new GlideRecord("sys_pd_context");
now_GR.addQuery("input_record", "Onboarding Case: ONB0001233");
now_GR.query();
while (now_GR.next()) {
sn_fd.FlowAPI.cancel(now_GR.getUniqueValue(), 'Canceling Test Flows');
}
Tried @Ankur Bawiskar solution with no success either.
https://www.servicenow.com/community/itsm-forum/cancel-running-flow-contexts/m-p/609487
The goal is from a current running Playbook check if a value on the case record is 'true'; "No Migration". If true, then cancel the associated sub-playbook so that it doesn't do migration activities. Otherwise, allow that sub-playbook to be completed; "Perform Migration".
Thank you,
-Wesley
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2023 09:44 PM
Hi Wesley,
Let me know if you found a solution for this issue, I want to do a similar thing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2024 01:41 AM
We also had to cancel a few playbooks and did this with the following command:
sn_playbook.PlaybookExperience.cancelPlaybook(process, reason);
process --> gr of sys_pd_context
reason --> String
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2024 02:44 AM
Hi @Markus9 , do you know if it's possible to restart a playbook via script? I'd like to restart playbooks of certain cases, but it has to be scripted. Any help would be appreciated!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2024 03:43 AM
Hi @JordyZ,
unfortunately I am not aware of any restart function. You may be able to do it in two steps:
- Cancel the playbook execution (see answer above)
- Trigger the playbook again
sn_playbook.PlaybookExperience.triggerPlaybook(scopedName, parentRecord);
scopedName --> scoped name of the playbook
parentRecord --> record to initiate a playbook for