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
08-22-2024 05:05 AM
Hi @Markus9 , it worked! I've been stuck on this issue for days, thank you so much.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2025 10:50 PM
Hi @Markus9 , Where do we need to run this line of code!? Cant we run this in background script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2025 09:41 PM
Yes, just run this as background script 🙂