How to stop running workflow?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2020 09:32 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2020 09:58 AM
You can do this in server script like below using setWorkflow() method
var ciGr = new GlideRecord('cmdb_ci_computer');
ciGr.addEncodedQuery('<whatever>');
ciGr.query();
while (ciGr.next()) {
ciGr.setWorkflow(false);
ciGr.autoSysFields(false);
ciGr.deleteRecord();
}
Regards,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2020 10:13 AM
Hi,
Please refer below threads it will help you,
docs.servicenow.com/bundle/orlando-servicenow-platform/page/administer/workflow-administration/task/t_CancelingAWorkflow.html
Hope this helps!
If I have answered your question, please mark my response as correct and/or helpful.
Thanks,
Sriram

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2020 10:19 AM
Hi,
Using simply setWorkflow(false); method in server-side.
Thanks,
Kunal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2020 10:27 AM
Hi,
you can cancel the workflow as below
Ensure you pass the record sys_id of the table on which the workflow is running
var gr = new GlideRecord('incident');
gr.get('sys_id');
var workflow = new Workflow();
workflow.cancel(gr); // where gr refers to the glide record object
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader