On change client script for reference variables

Ankita Gupte
Kilo Sage

Hello Experts,

 

I need you help on below:

 

I have two reference variables which are list collector (i.e. it will select multiple values)

1. Country

2. Location

 

So whenever country A is selected then Location under country A must be visible

If country B is selected then country under B must be visible.

 

This variables are created under multi row variable.

 

AnkitaGupte_0-1667891265396.png

 

Please help with onchange client script or if there is any other way to achieve it.

 

1 ACCEPTED SOLUTION

Please use it as below correctly replace the country field name and variable name

 

If the country is a reference field on the location table use the below:-

javascript:'u_crm_salesforce=true^countryfieldnameonloacation='+current.countryvaribalename;

 

If the country is text field on location table use the below:-

javascript:'u_crm_salesforce=true^countryfieldnameonloacation='+current.countryvaribalename.getDisplayValue();

 

Please mark my answer as correct based on Impact. 

View solution in original post

8 REPLIES 8

Hello,

 

Assuming the country name is correct for field and variable use it as below:-

 

javascript:'u_crm_salesforce=true^country='+current.variables.country.getDisplayValue();

 

Please see the screenshot below:-

 

Saurav11_0-1667904180211.png

 

Please mark my answer as correct based on Impact

Hope you are using list collector variable since I have this format

 

AnkitaGupte_0-1667904778153.png

Also now properties list is appearing only for first selection of country. If I select country B then no location under country B is visible.

It working fine with below Ref qualifier javascript:'u_crm_salesforce=true^countryIN'+current.variables.var_country.getDisplayValue();

 

Thank You for guiding. It was really helpful.

kamlesh kjmar
Mega Sage
Mega Sage

Hi @Ankita Gupte ,

 

It is not possible through client script, you will have to use reference qualifier for this. Use the below link, it will help you achieve your requirement:

 

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0746780

 

Regards,

Kamlesh