To use Group sys_id in place of name?

Chandler2
Tera Guru

I am using below code in an ACL to give access if user is member of that group. I want to use sys id instead of name so change in group name doesn't affect the code. What would be the code?

if (gs.getUser().isMemberOf('Program Senior Managers'))
{
answer = true;
} else
{
answer = false;
}

1 ACCEPTED SOLUTION

Pranesh072
Mega Sage
Mega Sage

You can pass the sys_id also 

 

gs.getUser().isMemberOf(<sys_id>)

View solution in original post

4 REPLIES 4

Harika Bhupathi
Giga Guru
Hi, From the group table, copy the sys I'd of that group and give in the place of name within quotes Mark my answer as correct or helpful if it resolved your issue Regards, Harika

Pranesh072
Mega Sage
Mega Sage

You can pass the sys_id also 

 

gs.getUser().isMemberOf(<sys_id>)

Also, be sure the group you are checking is  ACTIVE, otherwise the function will return false even though the user actually IS a member.  This is very confusing.  😕

Mario Quinones1
Mega Guru

FYI; gs.getUser().isMemberOf() works for both group name and group sys_id