How to access VariableSet's variables in Record Procuder Scripts.

sneha_chauhan
Tera Expert

I have a Variable Set (existing_printer) inside my record producer, I want to check value of a variable from variable set in my record producer script. I tried using producer.<variableSet_name>.<varibale_name> as below:

else if((producer.please_select_issue_description == "Break Fix/Issue") && (producer.existing_printer.what_type_of_department_printer == "HOD" ))
    {
        current.assignment_group.setDisplayValue('groupName');
}
 
1 ACCEPTED SOLUTION

sneha_chauhan
Tera Expert
Got the solution, below line of code is working:
producer.existing_printer[
0].what_type_of_department_printer == "HOD"
 
Thanks all for your quick response

View solution in original post

9 REPLIES 9

Yes, i am using Multi-row variable set.

 

sneha_chauhan
Tera Expert

@Ankur Bawiskar  Can you please help?

SHALIKAS
Tera Guru

There are two type of Variable Sets - single row, and multi row.  With both, there is not a no-code method to map the variables to a field.  In your producer Script, for a single row variable set, treat it as you would any other variable with the syntax

current.field_name = producer.variable_name;

A multi-row variable set requires a few more lines as you have to loop through the value for each row, so let me know if that's what you're dealing with, then you have to decide how you want to handle the mapping of multiple values to a single value field.

 

For variables outside of a variable set, it's always best to use the non-scripting method if it's a basic mapping with no lookup/manipulation needed as you are selecting the field by name rather than typing in the field name and variable name, so there's less room for error.

Are you really just copying answers from others on other questions without even reading the question properly? At least have the decency to quote the person giving the answer if you do a copy/paste: https://www.servicenow.com/community/guided-learning-itsm/how-to-access-variableset-s-variables-in-r...

 


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

sneha_chauhan
Tera Expert
Got the solution, below line of code is working:
producer.existing_printer[
0].what_type_of_department_printer == "HOD"
 
Thanks all for your quick response