How to stop running workflow?

ak4
Tera Contributor

How to stop running workflow?

10 REPLIES 10

sachin_namjoshi
Kilo Patron
Kilo Patron

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

sriram35
Kilo Guru

Hi,

 

 

Please refer below threads it will help you,

 

https://community.servicenow.com/community?id=community_question&sys_id=a57a47e9db5cdbc01dcaf3231f96...

 

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

Kunal Varkhede
Tera Guru

Hi,

 

Using simply setWorkflow(false); method in server-side.

 

Thanks,

Kunal

Ankur Bawiskar
Tera Patron
Tera Patron

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

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader