Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

How to cancel current workflow and start a new workflow

Tyler36
Tera Contributor

Hello i am creating a business rule that when triggered it stops the current workflow and will start a different workflow. Any ideas on how to achieve this? Thanks.

1 ACCEPTED SOLUTION

Anurag Tripathi
Mega Patron
Mega Patron

Hi

To start a new workflow and attach to the ticket

var wflw = new Workflow();
wflw.startFlow(wflw.getWorkflowFromName('give the workflow name'), gr, 'insert'); //gr is the record

 

To cancel the workflow

var w = new Workflow();
var gr = new GlideRecord(‘wf_context’);

if (gr.get(current.context)) // current is the record here
w.cancelContext(gr);

-Anurag

-Anurag

View solution in original post

5 REPLIES 5

Any specific reason to post the same script which I shared?

 

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