How do I set the RITM stage with Business Rule?

Rajanmehta
Mega Guru

Hello,

We are on Madrid version. I want to have a Business Rule on (sysapproval_approver) table, in which when approval is cancelled, I want to change RITM stage to request rejected. The reason for that is lot of time when approval is cancelled by System, the WF doesn't move next step.

Below is my Business Rule. Can you please help me out, how do I set the RITM stage to "Request Rejected"? 

I am getting the correct output in log on gs.log statement. (Marked with Green Arrow)

Please advise.

Thanks,

 

 

 

 

 

 

1 ACCEPTED SOLUTION

The SN Nerd
Giga Sage
Giga Sage

I would ordinarily manage this via the workflow through a rejection branch. It makes it easier to support when your logic is all in one place.

With regard to your Business Rule, I can see errors in your code.

Please see corrections below:

var appr = new GlideRecord('sysapproval_approver')
if ( appr.get(current.sys_id) ) {
	var ritm = new GlideRecord('sc_req_item');
	if ( ritm.get(appr.sysapproval) ) {
		ritm.setValue('approval','rejected');
		ritm.setValue('stage','request_rejected');
		ritm.update();
	}
}

 


ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

View solution in original post

2 REPLIES 2

The SN Nerd
Giga Sage
Giga Sage

I would ordinarily manage this via the workflow through a rejection branch. It makes it easier to support when your logic is all in one place.

With regard to your Business Rule, I can see errors in your code.

Please see corrections below:

var appr = new GlideRecord('sysapproval_approver')
if ( appr.get(current.sys_id) ) {
	var ritm = new GlideRecord('sc_req_item');
	if ( ritm.get(appr.sysapproval) ) {
		ritm.setValue('approval','rejected');
		ritm.setValue('stage','request_rejected');
		ritm.update();
	}
}

 


ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

Hi Paul,

Thanks for the correction. That was awesome. 

Thanks,

Rajan