- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2020 03:48 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2020 04:04 PM
Hi Deepak,
If you want to check on Server side i.e Business rule, background script, scheduled job etc. then here is the script.
var gr = new GlideRecord('sys_user_grmember'); // Table stores the mapping of user and group.
gr.addQuery('user', '<sys_id_user>'); // replace <sys_id_user> with actual sys_id of user.
gr.addQuery('group', '<sys_id_group>');// replace <sys_id_group> with actual sys_id of group.
gr.query();
if(gr.next()){
gs.info("User is Member of Group!");
}
else{
gs.info("User is Not a Member of Group!");
}
Please mark this correct & helpful if it answered your question.
Thanks & Regards,
Sharjeel
Muhammad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2020 08:53 PM
hi deepak,
Script to find whether users belong to a particular group or not.
query to see if user is in a group
Regards,
Krishna.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2020 09:52 PM
Hi Deepak,
Find below code.
var ourUser = gs.getUserID(); // here you will get sys id of user
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('user', ourUser); // checking user sys id here.
gr.addQuery('group', '0a52d3dcd7011200f2d224837e6103f2');// enter youe group sys id here
gr.query();
if(gr.next()){
gs.info("User is Member of Group!");
}
else{
gs.info("User is Not a Member of Group!");
}
Mark correct/helpful based on impact.
Thanks,
Dhananjay.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-25-2020 05:18 AM
Hi Deepak,
Did you get chance to work on my script?
If this has resolved kindly mark this as correct so others will refer same in future for same query and also by marking this as correct question will remove from unanswered thread.
Thanks,
Dhananjay.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-25-2020 04:58 AM
Hi Deepak
Along with the script provided by dhananjay,you can try my script also.
var usr = current.opened_by.getDisplayValue();
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('group','group name');
gr.addQuery('user',usr);
gr.query();
while (gr.next()){
gs.log('query ran');
if (gr.user != null){
gs.log('query found' + gr.user);
//do processing
}else{
gs.log('no user found')
}
}
in addition,you can refer this
Please Mark Correct and Helpful
Thanks and Regards
Gaurav Shirsat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2021 07:35 AM
try this one liner
gs.print(gs.getUser().getUserByID("c5d469004ffb4200704d09fd0210c760").isMemberOf("Name of the group"));