Remove the reference qualifier condition
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2023 02:21 AM - edited ‎07-03-2023 02:22 AM
Hallo,
I am trying to create a catalog client script. I have a checkbox field called 'user_not_visible' and a reference field called 'requested_for'. The reference field has a reference qualifier condition based on a field called 'Territory' to filter users based on their territory. When the checkbox is checked, I want to remove the reference qualifier condition and show all users in the reference field. However, the current script I have tried is not working as expected.
See images please
---------------------

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2023 02:37 AM
Hi,
Can you try below approach:
https://servicenowthink.wordpress.com/tag/how-to-modify-reference-qualifiers-with-client-script/
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-23-2024 08:51 PM - edited ‎06-23-2024 08:52 PM
Thanks Aman.
this article worked for me:
How to modify Reference Qualifiers with Catalog Client Scripts – ServiceNow – ServiceNow Think (word...
and this is the onChange client script:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2023 03:18 AM
Hi @Simo Shaf ,
Hope you are doing great.
To address your requirement, you can create a catalog client script that handles the behavior of the checkbox field and the reference field. The script will determine whether to apply the reference qualifier condition or remove it based on the state of the checkbox field.
Please refer to the code below:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
var requestForCheckbox = g_form.getValue('user_not_visible');
var referenceField = g_form.getControl('requested_for');
if (requestForCheckbox) {
referenceField.removeAttribute('glide_list_filter');
} else {
var condition = 'territory= Netherlands'; // Replace 'Netherlands' with your desired condition
referenceField.setAttribute('glide_list_filter', condition);
}
}
Regards,
Riya Verma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2023 03:29 AM
Hi @Riya Verma
Thanks! But it's the same, it doesn't work.