Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

On change client script for reference variables

Not applicable

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

Saurav11
Kilo Patron

Hello,

 

Which table are both field referencing to. Assuming the location field is referencing to cmn_location use a advance qualifier in the location variable:-

 

javascript:'countryfieldnameonloacation='+countryvaribalename;

 

Please mark my answer as correct based on Impact. 

Not applicable

Country field refers to core_country table

location field refers to cmn_location also we have one customize field on location form "u_crm_salesforce" and only true value of this fields will be visible in location field.

so I am already using reference qualifier as "u_crm_salesforce=true"

How can I modify this "javascript:'countryfieldnameonloacation='+countryvaribalename"

so that u_crm_salesforce value true location for selected countries will be visible

 

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. 

Not applicable

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

 

I used this it still shows all location under properties

 

I have selected country as bahrain but under properties it shows all location

 

AnkitaGupte_2-1667902799473.png

 

Also country is string field on location table

AnkitaGupte_1-1667902727507.png