How cancel RITM if SCTASK is closed incomplete using flow designer?

Ash41
Kilo Sage

Hi Team, 

 

I'm able to close the RITM when SCTASK is "closed complete". But, at the sametime if SCTASK is "closed incomplete" how to make RITM state "cancelled" using flow designer?

 

find_real_file.png

Regards, 

Ash

1 ACCEPTED SOLUTION

Hi,

then do this in the BR

Condition: State Changes to Closed Incomplete

Script:

(function executeRule(current, previous /*null when async*/) {

    // Add your code here

var ritm = current.request_item.getRefRecord()'

ritm.state = 'cancelled';

ritm.update();

})(current, previous);

Regards
Ankur

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

View solution in original post

8 REPLIES 8

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Ideally you should close the RITM once the last SC Task for that RITM is completed.

I would suggest to use after update BR on sc_task table

Regards
Ankur

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

Hi Ankur,

As we have many catalog items with flow designers for each, I think it is good idea to have an BR for cancelled state SCTASK to update RITM. 

Can you please help with script for BR?

Regards, 

Ash

Hi,

Once all sc tasks are closed for the RITM; RITM will be marked complete

You can have after update BR on sc_task

Condition: Active Changes to False

Script:

(function executeRule(current, previous /*null when async*/) {

	// Add your code here

	var gr = new GlideRecord('sc_task');
	gr.addQuery('request_item', current.request_item); 
	gr.addQuery('active', true);
	gr.query();
	if(!gr.next()){
		var ritm = current.request_item.getRefRecord(); 
		ritm.state = 3;
		ritm.update();

	}

})(current, previous);

Regards
Ankur

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

Hi Ankur, 

 

Can I use this above script for SCTASK "closed incomplete"  to change RITM state to "cancelled"?

Regards, 

Ash