Business Rule to Set RITM & Request State to Closed Incomplete when RITM Stage is Request Cancelled

WazzaJC
Tera Expert

Business Rule to Set RITM & Request State to Closed Incomplete when RITM Stage is Request Cancelled

 

Hi ServiceNow Community colleagues,

 

Please can I ask for your advice on the Business Rule I would need to configure the following:

 

I would like to set the Requested Item (RITM) and Request 'State' to 'Closed Incomplete' after the RITM 'Stage' = Request Cancelled. The Request 'Stage' is currently being set to Request Cancelled in a Flow, but I want a business rule outside of the Flow, to auto-set the RITM and REQ State to Closed Incomplete.

 

So as soon as the RITM 'Stage' is = 'Request Cancelled', I want the Business Rule to set the RITM 'State' to 'Closed Incomplete' and also the corresponding Service Request 'State' to 'Closed Incomplete'.

 

Would anyone kindly be able to share the Script and Conditions I need to configure for this Business Rule - how would it look?

 

Thanks very much as always.

2 ACCEPTED SOLUTIONS

swathisarang98
Giga Sage
Giga Sage

Hi @WazzaJC ,

 

You can Try after update BR

Table: sc_req_item

condition as shown below,

Note: better to keep your catalog item in condition so that it will not run for others,

swathisarang98_0-1708643909495.png

 In action, to update requested item state

swathisarang98_1-1708643944868.png

In advanced, to update Request table

swathisarang98_0-1708669576242.png

code

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

	var reqUpdate = new GlideRecord('sc_request');
	reqUpdate.addQuery('sys_id',current.request);
	reqUpdate.query();
	if(reqUpdate.next()){
		reqUpdate.state = 4 ;
		reqUpdate.request_state = 'closed_cancelled';
		reqUpdate.update();
	}

})(current, previous);

 

 

Please mark this comment as Correct Answer/Helpful if it helped you.

Regards,

Swathi Sarang

 

 

View solution in original post

Harish KM
Kilo Patron
Kilo Patron

Hi @WazzaJC there is OOB BR which does it when you cancel the RITM, Please check this BR on req item table

Close Parent if Required

Regards
Harish

View solution in original post

6 REPLIES 6

Harish KM
Kilo Patron
Kilo Patron

Hi @WazzaJC there is OOB BR which does it when you cancel the RITM, Please check this BR on req item table

Close Parent if Required

Regards
Harish

SunilKumar_P
Giga Sage

Hi @WazzaJC, We have a OOO Business rule 'Close Parent if Required' which handles the closure of parent based on the stage of RITM. Have you checked / tested this? If the OOB script is not working as per the need, then you can try the script shared by @swathisarang98 but just correct the line 6 as reqUpdate.next()

if(reqUpdate.next()){

 

Regards,

Sunil