Change RITM field when SCTASK field is changed

RobertPC
Tera Contributor

This may seem a little odd, but here we go. I want to create a business rule that does the following.

 

When the user changes the requested_for filed in the SCTASK then the opened_by filed in the RITM and the REQ are changed to the value that the requested_for was changed to. I'm not very good at writing scripts, I have tried building the logic, but am not having any luck. Any help would be greatly appreciated.

 

RobertPC_0-1706896327602.pngRobertPC_1-1706896366748.png

 

2 REPLIES 2

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @RobertPC 

 

May i know use case for this? Once a request submitted, why need to change the user?

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Sandeep Rajput
Tera Patron
Tera Patron

@RobertPC Here is how you should configure the business rule.

 

Screenshot 2024-02-02 at 11.41.18 PM.png

Screenshot 2024-02-02 at 11.47.33 PM.png

Here is the script.

 

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

	// Add your code here
	current.opened_by = current.requested_for+'';//Set Opened by on RITM
	var requestRef = current.request.getRefRecord();
	requestRef.setValue('opened_by',current.requested_for); //Set Opened by on Request
	requestRef.update();

})(current, previous);

 

Hope this helps.