How to Use RTTM Variables as condition in Business rule in RITM Table?

HARI KISHAN GVS
Mega Sage

Hi Team,

Can somebody help me on this.

i am trying to copy values from variables(which are in Variable set) to fields in RITM Table by using Business rule.

By using below script in my after business rule which is on the sc_req_item table values are not copied.

(function executeRule(current, previous /*null when async*/) {
// Note: if  i am using if condition like this values are NOT Copied. and if i remove if condition values are copied.

if((current.variables.standard_employee_questions.check_this_box=='true')&&(current.variables.standard_employee_questions.needed_by=='today')){
current.u_requestor = current.variables.standard_employee_questions.requested_for;
current.update();
}}

)(current, previous);

Please let me know how to resolve this? and i can't use run script activity in workflow as my variable set is used in multiple catalog items and they have different workflows. i don't want to modify all the workflows.

1 ACCEPTED SOLUTION

Brad Bowman
Kilo Patron
Kilo Patron

This works fine with a before Insert Business Rule.  When referring to variables in a workflow or BR script, use the syntax current.variables.variable_name, not current.variables.variable_set_name.variable_name, so this script will work.

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

	if(current.variables.check_this_box.toString() =='true' && current.variables.needed_by == 'today'){
		current.u_requestor = current.variables.requested_for;
	}

})(current, previous);

View solution in original post

8 REPLIES 8

Brad Bowman
Kilo Patron
Kilo Patron

This works fine with a before Insert Business Rule.  When referring to variables in a workflow or BR script, use the syntax current.variables.variable_name, not current.variables.variable_set_name.variable_name, so this script will work.

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

	if(current.variables.check_this_box.toString() =='true' && current.variables.needed_by == 'today'){
		current.u_requestor = current.variables.requested_for;
	}

})(current, previous);

HARI KISHAN GVS
Mega Sage

Hi Ankur and Brad,

Thanks for the Help!.

 

You are welcome.

Glad to help.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader