- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2022 11:09 PM
Hello,
Is there a way to filter the module to only include groups that I am a member of and of a certain type?
For example on, My Groups Work, since I do not have an admin role, I need to only see 3 groups on the filter instead of 4 groups since the Change Manager group does not have an itil type.
Is there a way to hide this if the user is not admin?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2022 03:50 PM
Please modify the code as below
function getMyGroupsCustom()
{
var ids = [];
var uID = gs.getUserID();
var isAdmin=gs.getUser().hasRole('admin');
var grmember = new GlideAggregate('sys_user_grmember');
grmember.addQuery('user', uID);
grmember.addQuery('group.active', true);
if(!isAdmin)
grmember.addEncodedQuery('group.typeNOT LIKE2e763549d7111100828320300e61038d');
grmember.groupBy('group');
grmember.query();
while(grmember.next())
{
ids.push(grmember.group.toString());
}
return ids;
}
Add the highlighted code in your script include, it will work as you are expecting.
If my answer replied your question please mark appropriate response as correct so that the question will appear as resolved for other users who may have a similar question in the future.
Regards,
Saurabh
Thanks and Regards,
Saurabh Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2022 02:21 PM
Oh nevermind, I know what I did wrong, apologies. It's working now though how can I make this only for non-admin users?
I mean this condition should only work if the logged in user does not have an admin role.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2022 02:22 PM
Oh nevermind, I know what I did wrong, apologies. It's working now though how can I make this only for non-admin users?
I mean this condition should only work if the logged in user does not have an admin role.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2022 03:50 PM
Please modify the code as below
function getMyGroupsCustom()
{
var ids = [];
var uID = gs.getUserID();
var isAdmin=gs.getUser().hasRole('admin');
var grmember = new GlideAggregate('sys_user_grmember');
grmember.addQuery('user', uID);
grmember.addQuery('group.active', true);
if(!isAdmin)
grmember.addEncodedQuery('group.typeNOT LIKE2e763549d7111100828320300e61038d');
grmember.groupBy('group');
grmember.query();
while(grmember.next())
{
ids.push(grmember.group.toString());
}
return ids;
}
Add the highlighted code in your script include, it will work as you are expecting.
If my answer replied your question please mark appropriate response as correct so that the question will appear as resolved for other users who may have a similar question in the future.
Regards,
Saurabh
Thanks and Regards,
Saurabh Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2022 04:01 PM
Hello,
It is now working, thanks so much for this. Appreciate all the help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2022 04:10 PM
Thanks
Thanks and Regards,
Saurabh Gupta