Based on user location remove options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2024 08:47 PM
Hi Team help me!!
I have a reference field which is opened for?
based on user location I need to remove options?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2024 09:36 PM
Hi @Vinya Jakkula
can you explain, what is the field type from which you need to remove the options.
Explain to solve it efficiently.
Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..
- Keep Learning
Thanks & Regards
Deepak Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2024 09:55 PM
@Deepak Shaerma It is select box.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2024 10:01 PM
Hi @Vinya Jakkula
Common approach for removing the field value based on user location is mostly fulfilled by both server side and client side scripting. in your case i provide on change client script
On Change for Req for
if (newValue) {
var userGR = new GlideRecord('sys_user'); // Adjust ‘sys_user’ if your user table has a different name or sys_id needs to be queried from another table.
userGR.get(newValue); // Here, newValue is the sys_id of the selected caller
if (userGR.location == 'sys_id_of_Location_A') { // Replace ‘sys_id_of_Location_A’ with the actual sys_id of Location A.
// Now remove the option from the select box
var selectBox = g_form.getGlideUIElement('your_select_box_field'); // replace ‘your_select_box_field’ with the actual field name
if (selectBox) {
selectBox.removeOption('value_of_option_A'); // Replace ‘value_of_option_A’ with the value of the option you want to remove
}
}
}Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..
- Keep Learning
Thanks & Regards
Deepak Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2024 10:02 PM
you can write onChange + getReference callback and get the location and then remove the options using
g_form.removeOption('fieldName', 'choiceValue');
what script did you start with and where are you stuck?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
