Reference Qualifier on Variable Set based on Variable on the record producer

rashmianish
Kilo Expert

Hi All,

I have a record producer with few variables and a variable set. A variable named 'Client name' is created as a variable and the Variable set has Policy details.

Requirement is - based on the Client name selected in the 'Client name' field, the policy type and policy number should be filtered. I have tried writing a catalog client script on the variable set; however Variable on the form is not available to write Onchange/ Onload while writing the script on variable set. Any help on this is much appreciated. 

find_real_file.png

 

7 REPLIES 7

How was this issue resolved?

Maren R
Tera Contributor

I had a similar use case where I had a field on the record producer itself called "Region" and then a reference field on the multirow variable set called "Location" which was supposed to be filtered based on the users selection on the "Region" field. 

I solved it by adding an additional field on the multirow variable set to hold the same value as the "Region" field. Then I populated this value and hid it (as it did not need to be visible) using an onLoad "Catalog client script" on the variable set like this:

 

function onLoad() {
   if (g_service_catalog.parent.getValue('region')) {
    g_form.setValue('region_mrvs', g_service_catalog.parent.getValue('region')); // Set value based on "Region" field on the main record producer
	g_form.setDisplay('region_mrvs', 'false'); // Hide field
} 
}

 

 

Then I used an advanced reference qualifier to filter the "Location" field on the multirow variable set based on this new, hidden "region_mrvs" field:

 

 

javascript: "region=" + current.variables.region_mrvs;

 

 


I saw this was an old thread, but maybe it can help someone else 🙂

 

 

This article details a way to do the same without creating and mostly hiding another variable

https://www.servicenow.com/community/now-platform-articles/yes-you-can-effectively-set-or-update-a-r...