We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Incident opened by group info

VENKAT SHIVA KI
Tera Contributor

Hi

 

How do I check if the Opened by (reference field) on an incident is part of a specific group through scripting.

gs.isMemberOf() is from GildeSession and this is not working on Glide Record.

 

Thanks

Kiran

1 REPLY 1

Anirudh Pathak
Giga Sage

Hi @VENKAT SHIVA KI ,

Here is a server side code to check if user is part of the group or not - 

 

var member = new GlideRecord('sys_user_grmember');
member.addQuery('user', current.opened_by); // replace "current.opened_by" with the actual field name
member.addQuery('group', '<sys_id_group>');// replace <sys_id_group> with actual sys_id of group.
member.query();

if(member.next()){
  gs.info("User is Member of the Group");
}
else{
  gs.info("User is Not a Member of the Group");
}