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

Hello Stefan,

I tested your solution and just wanted to let you know that this wont work on Portal. It works fine in normal UI but wont work on Service Portal.

As a work around i do the following:

1. Create an onChange client script for the variables.company variable and store the value in a "parent.companyID" value.

function onChange(control, oldValue, newValue, isLoading) {
  if (isLoading || newValue == '') {
    return;
  }
  parent.parentCompanyID = newValue;
}

2. Create an onLoad client script in the Multi Row variable and do something like

 function onLoad() {
  
  //Set company ID to field
  g_form.setValue('companyid', parent.parentCompanyID);
}

PS: There is also the following: g_service_catalog.parent.getValue('company')

The above works in Portal and in normal UI.

Link

Cheers,
Manolis.

Hello Manolis,

I only had this requirement for the normal UI so i did not test it on the portal. Maybe i had to mention this in my post. Do i see a little typo in your client script at step 1? 

"parent.parentCompanyID = newValue;" should be: "parent.CompanyID = newValue;"

Thank you for testing this and creating a work around!

Regards,

Stefan

You are right, just corrected the typo.

The first part is a "dirty workaround". I think the best solution would be the function from SNOW:

g_service_catalog.parent.getValue('company')

I also linked the related doc.

Cheers,
Manolis.