Cancel the existing flow and attach new one

rohitservicenow
Mega Guru

Hi, 

We had to make changes to a flow as it had a bug. Now when I moved the corrected to flow to Production, want to cancel the existing flows which are attached to the RITMs. So to attach the new flow to the existing RITMs, I tried TEST, but I keep receiving error. Wondering if there is any other way of attaching the new flow? 

thank you,

Rohit

3 REPLIES 3

Alberto Consonn
ServiceNow Employee
ServiceNow Employee

Hi Rohit,

it's really NOT best practice to cancel an existing RITM Workflow and force a new one, the reason is well explained by randrews here:

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

However, you could potentially give a try using the script suggested by benoit here in a no-production instance, anyway I really doubt this will solve your requirement:

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

If I have answered your question, please mark my response as correct and/or helpful.

Thank you very much

Cheers
Alberto

Lucas Alves
Giga Guru

Hi,

Try to use this API's for workflow:

//cancel workflow.
var oldWorkflow = new Workflow();
oldWorkflow.cancel(gr);

//start new workflow
var newWorkflow = new Workflow();
var operation = 'insert';

 

Example:

var gr = new GlideRecord("my_table"); // Access the table.
gr.addQuery("sys_id", "45ae539e4f73fb4487418d9f9310c7fc"); // Record lookup
gr.query();
if (gr.next()) {

//cancel workflow.
var oldWorkflow = new Workflow();
oldWorkflow.cancel(gr);

//start new workflow
var newWorkflow = new Workflow();
var operation = 'insert';

// Determines which Workflow will change (WF record sys_id, not WF version)
var context = newWorkflow.startFlow('93522c0cdbcf5f00b3cd73e1ba9619e1', gr, operation);

}

 

Please mark my answer as Helpful and Correct Answer if I was able to help you.

Hello Lucas,

Can we perform similar operation for "Flow Designer"?
V.I.Z.  cancel the running Flow-Context  and attach the new Flow?