Business rule script variable "undefined"

glawson_pgatss
Tera Contributor

Hey all,

 

I am working on creating a business rule that will set the short description of an incident inserted to "Compensation Change: " +producer.variable_name.

 

When I test the script the short description comes back as: "Compensation Change: Undefined" no matter what I append to the script.

 

For reference I have appended a screen snip of the script itself. In addition the "comp_associate_name" is a reference field to the sys_user table and it displays information correctly within the record producer itself, which also has a screen snip attached.

 

Any assistance is greatly appreciated as this has been a hard stop and I am working to resolve this problem in my environment.

 

Thank you in advance!

1 ACCEPTED SOLUTION

Nick Parsons
Mega Sage

For variables, you should use current.variables.<variable_name> where your replace <variable_name> with the particular variable you're trying to access. Since it's a reference field that you're trying to access, you'll also want to call .getDisplayValue() on your variable:

 

current.work_notes = "Compensation Change: " + current.variables.comp_associate_name.getDisplayValue() + "\n";

View solution in original post

3 REPLIES 3

Nick Parsons
Mega Sage

For variables, you should use current.variables.<variable_name> where your replace <variable_name> with the particular variable you're trying to access. Since it's a reference field that you're trying to access, you'll also want to call .getDisplayValue() on your variable:

 

current.work_notes = "Compensation Change: " + current.variables.comp_associate_name.getDisplayValue() + "\n";

James Chun
Kilo Patron

Hey @glawson_pgatss,

 

You should be using the Record Producer script for this, not a Business Rule.

 

The script will be something like:

current.short_description = "Compensation Change: " + producer.variable_name;

 

Cheers

Harish KM
Kilo Patron
Kilo Patron

Hi @glawson_pgatss Since this is a record producer, you dont need a Business rule on incident table to do this, you can use script section of the record producer to map the variables like below

// for reference field need to use getDisplayValue()
current.short_description = "Compensation Change: "+producer.variableName.getDisplayValue();

 

HarishKM_2-1709686684916.png

 

 

 

Regards
Harish