Hide an option in reference field based on user role on record producer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2024 11:35 PM
Hi Team , I have a requirement to hide one option(ex: A) in reference field based on user role, for non-ITIL users option should not be visible on the form. Could you please help me on how to achieve this.
I have tried the on load script but its not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2024 03:47 AM
then you should use advanced ref qualifier to filter it
something like this
javascript: var query = ''; if(!gs.hasRole('itil')) query = 'sys_idNOT INsysId1'; query;
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2024 04:18 AM
@Ankur Bawiskar , i have checked there is one reference qualifier already, could you please help , how can i add the above ref qualifier mentioned by you . PFB screenshot. Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2024 04:27 AM
you have a script include function called
share that function code here and also the complete ref qualifier here and not screenshot
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2024 05:54 AM
@Ankur Bawiskar , here is script include and ref Qualifier
Ref qualifier: javascript:'u_active=true^u_for_gefco=false^'+new incidentServerUtils().getService(current.variables.caller_id);
script Include:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2024 06:00 AM
update as this
var incidentServerUtils = Class.create();
incidentServerUtils.prototype = {
getService: function(cur) {
// var GlideCatg = new GlideRecord('u_categories');
// GlideCatg.addQuery('u_assignment_group',)
var query = '';
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id', cur);
gr.query();
if (gr.next()) {
var assigneeLoc = gr.location.country;
}
if (assigneeLoc != '') {
var GlideCatg = new GlideRecord('u_categories');
GlideCatg.addQuery('u_location', assigneeLoc);
GlideCatg.query();
if (GlideCatg.next()) {
query = 'u_location=' + assigneeLoc + '^ORu_location=';
} else {
query = 'u_location=' + 'Global' + '^ORu_location=';
}
} else {
query = 'u_location=' + 'Global' + '^ORu_location=';
}
if (!gs.hasRole('itil'))
query = query + 'sys_idNOT INsysId1';
return query;
},
isPublic: function() {
return true;
},
type: 'incidentServerUtils'
};
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader