Cancelling All RITM's in order guide, if one RITM cancelled or rejected

Anitha P
Tera Contributor

Hi Team,

 

I have one requirement. For Ex : We are having an one order guide, and we are raising the request from that order guide. That order guide request contains 4 RITM's. If first "RITM" got cancelled or rejected, other "RITM's" also should get cancelled. I have tried it with the business rules. But, didn't get a proper resolution. Any one please help me with the script. Thanks in advance.

 

With Regards,

Anitha P.

2 REPLIES 2

AnveshKumar M
Tera Sage
Tera Sage

Hi @Anitha P ,

 

Please try with this script in after insert/update business rule on sc_req_item.

 

AnveshKumarM_0-1678273711315.png

 

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

	var reqGr = new GlideRecord('sc_req_item');
	reqGr.addQuery('request', current.request);
	reqGr.query();
	while(reqGr.next()){
		reqGr.state = 4;
		reqGr.stage = 'closed_incomplete';
		reqGr.update();
	}

})(current, previous);

 

But this will trigger for all order guides, if you want to restrict it to a specific order guide there is no direct way, because neither the request nor the request item will contain the order guide it is ordered from in OOB.

 

To overcome this, you can create a custom field on sc_request table and reference it to the Order Guide. Then you can use the condition builder in business rule to trigger only if the request is from that specific order guide.

 

Thanks,

Anvesh

 

 

Thanks,
Anvesh

Hi Anvesh,

Thanks for replying. I got the solution. 

 

Thanks,

Anitha P.