The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Onchange Reference Qualifier in Catalog item

Mike Strik
Tera Guru

 

I'm trying to get this Onchange client script to work.

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
    
    var locationField = g_form.getControl('locatie');
    
    if (newValue == '5') {
        // Set the reference qualifier for "locatie" when "rollen" is 5
        locationField.setAttribute('reference_qual', 'u_location_statusIN0,1^u_locatie_typeINHoofdlocatie,Hoofdlokatie,Terrein,Ruimte,Terreindeel');
    } else if (newValue == '2') {
        // Set the reference qualifier for "locatie" when "rollen" is 2
        locationField.setAttribute('reference_qual', '^u_location_status=3');
    } else {
        // Reset the reference qualifier if "rollen" is neither 5 nor 2
        locationField.removeAttribute('reference_qual');
    }
}

 

 

1 ACCEPTED SOLUTION

Vishal Birajdar
Giga Sage

Hi @Mike Strik 

 

Can you put advanced reference qualifier directly on "locatie" field

 

javascript: 

var query ;

if (current.variables.<variable name on which you are writing onChange script> == '5') {

query =u_location_statusIN0,1^u_locatie_typeINHoofdlocatie,Hoofdlokatie,Terrein,Ruimte,Terreindeel';

} else if (current.variables.<variable name on which you are writing onChange script> == '2') {

query ='u_location_status=3';

};

 

No need to write onChange client script on variable here.

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

View solution in original post

2 REPLIES 2

Harish Bainsla
Kilo Patron
Kilo Patron

use in first line

var locationField = g_form.getValue('field name');

Vishal Birajdar
Giga Sage

Hi @Mike Strik 

 

Can you put advanced reference qualifier directly on "locatie" field

 

javascript&colon; 

var query ;

if (current.variables.<variable name on which you are writing onChange script> == '5') {

query =u_location_statusIN0,1^u_locatie_typeINHoofdlocatie,Hoofdlokatie,Terrein,Ruimte,Terreindeel';

} else if (current.variables.<variable name on which you are writing onChange script> == '2') {

query ='u_location_status=3';

};

 

No need to write onChange client script on variable here.

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates