How to add the work notes when catalogue variables are changed on RITM Form

Suresh36
Tera Expert

Work notes must be updated (with previous and current values) in RITM form if the catalogue variables have changed in RITM form.

 

Business Unit and Location both are catalogue variables and dropdown fields, PFA

Thanks in Advance!

 

Suresh36_0-1689339387704.png

 

1 ACCEPTED SOLUTION

Ahmmed Ali
Mega Sage

Hello @Suresh36 

 

You can use previous object in business rule script to get previous value and check with current value and add work notes based on the same.

Example script below: 

Business Rule type is before update on RITM table

 

 

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

	// Add your code here
	var workNotes = "Below variable values are changed:\n";
	var variablesUpdated = false;

	if(current.variables.location != previous.variables.location){
		workNotes += "\nLocation old value: " + previous.variables.location + "\t   Location new value: " + current.variables.location;
		variablesUpdated = true;
	}

	if(current.variables.business_unit != previous.variables.business_unit){
		workNotes += "\nBusiness Unit old value: " + previous.variables.business_unit + "\t   Business Unit new value: " + current.variables.business_unit;
		variablesUpdated = true;
	}
	
	if(variablesUpdated){
		current.work_notes = workNotes;
	}

})(current, previous);

 

 

Note: Replace variable names as per your configuration in the script

 

Thank you,

Ali

 

 

If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali

View solution in original post

1 REPLY 1

Ahmmed Ali
Mega Sage

Hello @Suresh36 

 

You can use previous object in business rule script to get previous value and check with current value and add work notes based on the same.

Example script below: 

Business Rule type is before update on RITM table

 

 

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

	// Add your code here
	var workNotes = "Below variable values are changed:\n";
	var variablesUpdated = false;

	if(current.variables.location != previous.variables.location){
		workNotes += "\nLocation old value: " + previous.variables.location + "\t   Location new value: " + current.variables.location;
		variablesUpdated = true;
	}

	if(current.variables.business_unit != previous.variables.business_unit){
		workNotes += "\nBusiness Unit old value: " + previous.variables.business_unit + "\t   Business Unit new value: " + current.variables.business_unit;
		variablesUpdated = true;
	}
	
	if(variablesUpdated){
		current.work_notes = workNotes;
	}

})(current, previous);

 

 

Note: Replace variable names as per your configuration in the script

 

Thank you,

Ali

 

 

If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali