Acessing variables in Advanced Reference Qualifier from a variable set

Javi2
Kilo Contributor

I have a Record Producer with this structure.

Record Producer{

         Variable 1

         Variable Set {

                  Variable 2

         }

}

 

Variable 1 is inside the record producer but Variable 2 is in a variable set. I want to use variable 1 value to filter Variable 2 using an advanced  reference qualifier but 'current.variables' refers to the variables in the variable set so I can't access variable 1.

 

Is there any way to achieve this?

 

Edit: This is a multi-row variable set.

 

1 ACCEPTED SOLUTION

Not sure if Variable 2 is the one that needs the reference qualifier, but according to the documentation Service catalog variable sets:

Note:

  • onSubmit catalog client scripts are not supported for a multi-row variable set.
  • Catalog UI policies and catalog client scripts defined at the item level are not applicable for variables in a multi-row variable set. Only those catalog UI policies and catalog client scripts defined within the multi-row variable set are applicable for variables in the multi-row variable set.
  • Scripts that are not included in a multi-row variable set cannot affect variables inside the multi-row variable set. Similarly, the scripts included in the multi-row variable set cannot affect the variables that are not included in the multi-row variable set.
  • Variables that are not included in a multi-row variable set cannot be used in dependent reference qualifiers for variables in the multi-row variable set. Similarly, the variables included in the multi-row variable set cannot be used in dependent reference qualifiers for variables that are not in the multi-row variable set. For a reference qualifier, the current row is the one that is being edited.

 

This may be why it is not working.

View solution in original post

12 REPLIES 12

sachin_namjoshi
Kilo Patron
Kilo Patron

You need to write script include and refer this script include in variable reference qualifier.

 

Check below for solution

 

https://community.servicenow.com/community?id=community_question&sys_id=9561d72ddbdcdbc01dcaf3231f961990

 

Regards,

Sachin

 

 

 

This only works if both variables are in the same "part" of the record producer.

current.variables refers to the variables inside the record producer when I call the script from the record producer (in my example variable 1 and the variable set) or it refers to the variables inside the variable set if I call the script from inside the variable set (variable 2 only).

 

I can't access variable 1 from a script called in the reference qualifier of variable 2 using current.variables.variable_1

 

find_real_file.png

 

The variable tipo (it's inside the variable set is defined) but origen ins't (it's on the 'parent' record producer)

ccajohnson
Kilo Sage

What you may want to do is create a third variable that is like Variable 1 in the variable set and hide it. Then, when Variable 1 changes copy the value of Variable 1 to Variable 3 so you can use Variable 3 in your reference qualifier.

Javi2
Kilo Contributor

I've tried this but I can't get it to work. I think it is because in a multi-row variable set I have to access the variables like this.

current.variables.multirow.getRow(i).variable

But there may not be rows created when I change the value of Variable 1.

 

Is there any way to change the Default Value of a variable from a script?