- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2023 04:17 AM
Hello All,
I created a custom field called "Special Group".
Field type "List":
Reference to "sys_user" table
In that field we need to show only a particular group members.
I written Script include like this:
var GetUsersOfGroup = Class.create();
GetUsersOfGroup.prototype = {
initialize: function() {
},
getUsersFromAppEngineAdminsGroup: function() {
var userList = [];
var groupGr = new GlideRecord('sys_user_grmember');
groupGr.addEncodedQuery('group=477a05d153013010b846ddeeff7b1225');// sys_id of App Engine Admins group
groupGr.query();
while (groupGr.next()) {
var user = new GlideRecord('sys_user');
if (user.get(groupGr.user)) {
userList.push(user.name.toString()); // Assuming name is used as the reference field
}
}
return userList;
},
type: 'GetUsersOfGroup'
};
how should i call this in that field "Special group" reference qualifier so that only
Please correct me if i did anything wrong.
2. In the list it showing sys_id's, how should we show user "names instead of sys_ids"?
@Ankur Bawiskar @SANDEEP28 @Community Alums
Thanks,
Abdul
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2023 04:34 AM
update script include as this
var GetUsersOfGroup = Class.create();
GetUsersOfGroup.prototype = {
initialize: function() {
},
getUsersFromAppEngineAdminsGroup: function() {
var userList = [];
var groupGr = new GlideRecord('sys_user_grmember');
groupGr.addEncodedQuery('group=477a05d153013010b846ddeeff7b1225');// sys_id of App Engine Admins group
groupGr.query();
while (groupGr.next()) {
userList.push(groupGr.getValue('user'));
}
return 'sys_idIN' + userList.toString();
},
type: 'GetUsersOfGroup'
};
Call it like this from the advanced ref qualifier
javascript: new GetUsersOfGroup().getUsersFromAppEngineAdminsGroup();
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-04-2023 06:12 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2023 06:16 AM
Glad to know.
Please mark my response as correct and close the thread.
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-04-2023 06:46 PM
Could you mark my response as correct and close the thread?
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-04-2023 09:57 PM