How to filter module to only include groups I am a member of and of a certain type

Evren Yamin
Tera Contributor

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?

find_real_file.png

 

1 ACCEPTED SOLUTION

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

View solution in original post

19 REPLIES 19

Saurabh Gupta
Kilo Patron
Kilo Patron

Hi,

Add additional condition in the query assignment_group.type ="your_type".

 

 

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

If I do this then I can still see the Change Manager on the filter. 

Please share the screenshot.


Thanks and Regards,

Saurabh Gupta

I need to hide the Change Manager on the filter itself since the type of the group is itil and I need to only include those that does not have an itil type

find_real_file.png