The CreatorCon Call for Content is officially open! Get started here.

How to cancel particular existing running workflow

Rameshnathan
Tera Expert

Hi

I have one custom table and i am inserting record on the table whenever changing state is pending the Incident table

1. Once Record is created on my custom table one workflow will run on the record

2. if they changing the state form pending to active then again changing active to Pending state in incident table means another one record will insert in my custom table

in this case i want to cancel my previous record workflow

How to achieve this..?

Thanks

1 ACCEPTED SOLUTION

Hi Ashutosh,



Can i do like this,



I have running one Before Insert BR on my custom table and running this script....



var rec = new GlideRecord('on_hold_state');


rec.addQuery('number', current.number);


rec.query();


if (rec.next()) {


var workflow = new global.Workflow();


workflow.cancel(rec);


gs.info("Existing Recors is " + rec.sys_id);



}



actually this is working but i just want to know whether this is correct method or not


View solution in original post

8 REPLIES 8

Hi Ashutosh,



Can i do like this,



I have running one Before Insert BR on my custom table and running this script....



var rec = new GlideRecord('on_hold_state');


rec.addQuery('number', current.number);


rec.query();


if (rec.next()) {


var workflow = new global.Workflow();


workflow.cancel(rec);


gs.info("Existing Recors is " + rec.sys_id);



}



actually this is working but i just want to know whether this is correct method or not


I want to know it will impact other running workflow or not..


Hi Ramesh,



This will cancel rec workflow. No impact on other things.



Thank you