How to stop flow designer from business rule

Saloni9
Giga Contributor

Hi,

I want to stop flow designer from the Business rule. We have a requirement to copy the state of SCTASK on the RITM. In some catalog items there are more than 1 SCTASKs. I write the below business rule on after , state changes to closed incomplete or state changes to closed skipped

var gr = new GlideRecord('sc_req_item');
gr.get(current.request_item);
//gr.addQuery('sys_id', current.parent);
gr.state = current.state;
gr.stage = 'Request Cancelled';
//gr.setWorkflow(false);
gr.update();

But because of OOTB br(cancel flow on request cancelled) all the sctasks are changing to closed Incomplete. 

Please help in this.

 

Many thanks!!

Saloni

15 REPLIES 15

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

why not update the flow condition?

is flow not stopping from triggering when you use setWorkflow(false)

Regards
Ankur

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

No @Ankur Bawiskar setWorkflow(false) is not working.

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you can use this script to cancel the flow which started

var flow = new GlideRecord("sys_flow_context");
flow.addQuery('name', 'Your Flow Name');
flow.addQuery('source_record', current.getUniqueValue());
flow.query();

if (flow.next()) {

	//get your flow's context
	var gpa = new sn_ph.GlideProcessAutomation(flow.getValue('sys_id'));

	//if the flow isn't terminated (see UI Action condition)
	if (!gpa.isTerminated()) {
		//cancel the flow and provide the reason
		gpa.cancel('Cancelling this flow');
	}
}

Regards
Ankur

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

Thank you but this is for specific flow. I want for all flow designer.