- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2024 05:25 AM
i want to call my script include into the advanced reference qualifier and this my script include
Reference Qual | javascript:new groupManager().findITILManager() |
in the background script it work but when i use the search icon it give all the users
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2024 06:00 AM - edited 08-30-2024 06:01 AM
You need to return a query string. Currently you are only returning an array of user sys ids. Your code would look like this, changing your return value
var groupManager = Class.create();
groupManager.prototype = {
initialize: function() {
},
findITILManager:function(){
try{
var users=[];
var gr = new GlideRecord("sys_user_has_role");
gr.addEncodedQuery('role.name=itil');
gr.query();
while (gr.next()) {
users.push(gr.user.sys_id);
}
return 'sys_idIN' + users.join(',');
}catch(error){
gs.error(error);
}
},
type: 'groupManager'
};

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2024 06:07 AM
@salaheddinezaf1 Here is the script you should try.
var groupManager = Class.create();
groupManager.prototype = {
initialize: function() {
},
findITILManager:function(){
try{
var users=[];
var gr = new GlideRecord("sys_user_has_role");
gr.addEncodedQuery('role.name=itil');
gr.query();
while (gr.next()) {
users.push(gr.getValue('user'));
}
return 'sys_idIN'+users.toString();
}catch(error){
gs.error(error);
}
},
type: 'groupManager'
};
Hope this helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2024 06:00 AM - edited 08-30-2024 06:01 AM
You need to return a query string. Currently you are only returning an array of user sys ids. Your code would look like this, changing your return value
var groupManager = Class.create();
groupManager.prototype = {
initialize: function() {
},
findITILManager:function(){
try{
var users=[];
var gr = new GlideRecord("sys_user_has_role");
gr.addEncodedQuery('role.name=itil');
gr.query();
while (gr.next()) {
users.push(gr.user.sys_id);
}
return 'sys_idIN' + users.join(',');
}catch(error){
gs.error(error);
}
},
type: 'groupManager'
};

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2024 06:07 AM
@salaheddinezaf1 Here is the script you should try.
var groupManager = Class.create();
groupManager.prototype = {
initialize: function() {
},
findITILManager:function(){
try{
var users=[];
var gr = new GlideRecord("sys_user_has_role");
gr.addEncodedQuery('role.name=itil');
gr.query();
while (gr.next()) {
users.push(gr.getValue('user'));
}
return 'sys_idIN'+users.toString();
}catch(error){
gs.error(error);
}
},
type: 'groupManager'
};
Hope this helps.