Exclude a group of users from reference field which is using sys_user as reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2019 07:36 AM
Hello
I have a requirement where in reference field which is of reference sys_user table we need to exclude IT group people from the list
How to to solve this
I found this article but not sure how to use this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2019 07:55 AM
The reference qualifier just needs to get your subset of users and return a query string that will exclude them from the query when the field is opened. Create a script include and name it excludeITUsers. When you tab out it should populate the script field with some code which is defining the class. Add the following code in the bit it tells you to:
//name your function
excludeITUsers: function(){
//create an array
var arr = [];
//glide into the user group table
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('group', 'sys_id of the IT group');
gr.query();
//add it users sys_id to the array
while(gr.next()){
arr.push(gr.getValue('user');
}
//return the query string to say sys id is not one of the it guys
return 'sys_idNOT IN' + arr;
}
Call it as per that link:
javascript: new excludeITUsers().excludeITUsers()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2019 09:52 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2019 12:39 AM
ok so you've configured it as a classless script include so you will need to call it in the advanced reference qualifier as below:
javascript: excludeIT()