Cancel the existing flow and attach new one
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2020 06:12 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2020 06:19 AM
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:
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:
If I have answered your question, please mark my response as correct and/or helpful.
Thank you very much
Cheers
Alberto

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2020 06:27 AM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2022 10:44 PM
Hello Lucas,
Can we perform similar operation for "Flow Designer"?
V.I.Z. cancel the running Flow-Context and attach the new Flow?