- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2023 03:15 AM
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');
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2023 04:14 AM
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.
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2023 03:41 AM
use in first line
var locationField = g_form.getValue('field name');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2023 04:14 AM
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.
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates