- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2024 11:34 AM - edited 05-09-2024 11:36 AM
Hi
I'm trying to create a catalog item so that itil user could choose user's / groups with who they want to share a specific report.
So i'm stuck with the group portion.
I did create a list collector with sys_user_group table.
With this reference qualifier that i found on the community
javascript:'sys_idIN'+gs.getUser().getMyGroups()
This code is working but the issue i got is that from the list collector some groups should not be visible.
Is there a way to filter out some groups ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2024 01:19 PM
Hi @flsn2 ,
There is no direct way to show logged in user group and filter out some group, inorder to achieve this you have to create a script include and call that in your reference qualifier.
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Swathi Sarang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2024 01:50 PM
@flsn2 ,
Please find the working example,
Reference qualifier,
Script include:
Code:
var getMyGroupList = Class.create();
getMyGroupList.prototype = {
initialize: function() {},
getGrouplist: function() {
var sysId = gs.getUserID();
//gs.info('sys id ' + sysId);
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('user', sysId);
gr.addEncodedQuery('group!=287ee6fea9fe198100ada7950d0b1b73^ORgroup=NULL'); //added encoded query that group is not DATABASE
gr.query();
var arr = [];
while (gr.next()) {
arr.push(gr.getValue('group'));
}
//gs.info('array ' + arr);
return 'sys_idIN'+arr.toString();
},
type: 'getMyGroupList'
};
Result:
I had 4 group ,
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Swathi Sarang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2024 01:19 PM
Hi @flsn2 ,
There is no direct way to show logged in user group and filter out some group, inorder to achieve this you have to create a script include and call that in your reference qualifier.
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Swathi Sarang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2024 01:50 PM
@flsn2 ,
Please find the working example,
Reference qualifier,
Script include:
Code:
var getMyGroupList = Class.create();
getMyGroupList.prototype = {
initialize: function() {},
getGrouplist: function() {
var sysId = gs.getUserID();
//gs.info('sys id ' + sysId);
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('user', sysId);
gr.addEncodedQuery('group!=287ee6fea9fe198100ada7950d0b1b73^ORgroup=NULL'); //added encoded query that group is not DATABASE
gr.query();
var arr = [];
while (gr.next()) {
arr.push(gr.getValue('group'));
}
//gs.info('array ' + arr);
return 'sys_idIN'+arr.toString();
},
type: 'getMyGroupList'
};
Result:
I had 4 group ,
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Swathi Sarang