I Created a Script Include to get users based on group type 'Problem Manager'.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2020 12:22 PM
All,
I created a script include below to return the sys_ids of the users where their group has a 'group type' = Problem Manager. I have added the group type to those specific groups. However when selecting the Problem Manager field the list is empty. Members in the group have the itil role.
Reference qual on the Problem Manager reference field:
javascript:new PrbMgrUtil().filterByType();
Script include:
var PrbMgrUtil = Class.create();
PrbMgrUtil.prototype = {
initialize: function() {},
filterByType: function(group_id) {
//Will show only users who are members of the specified group with type = Problem Manager
var found_users = [];
var gr = new GlideRecord("sys_user_grmember");
gr.addQuery("group", group_id);
gr.addQuery("type", 'Problem Manager');
gr.addNotNullQuery("user");
gr.query();
while (gr.next()) {
found_users.push(gr.user.sys_id.toString());
}
var ref_qual = "sys_idIN" + found_users.join(",");
return ref_qual;
},
type: 'PrbMgrUtil'
};
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2020 12:27 PM
Hi Brett,
Replace gr.addQuery("type", 'Problem Manager'); with gr.addQuery("group.type", 'Pass SysId of the Problem Manager record');
- Pradeep Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2020 01:31 PM
Thank you, Pradeep that was it and i also needed as you can see in my script. I had to pass the sys_id of the specified group.
Is there a better to do this if there are more than 1? I would hate to have to always update the script with a group sys_id.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2020 02:34 PM
Hi Brett,
You can build your query easily via an encoded query and copy it. Details here.
For reference, the AND condition for group type will look something like this gr.addQuery("group.typeLIKE74af88c6c611227d0066386e74dc853d^group.typeLIKE2e763549d7111100828320300e61038d");
Note: To make it more configurable you can store the sys_id values in system properties and fetch the values via script.
https://www.servicenowguru.com/system-definition/working-with-system-properties/
- Pradeep Sharma