Checking users group membership via an acl

Cirrus
Kilo Sage

Hi, 

I know the below code is wrong as gs.getUser() refers to the current logged in user.

 

if(gs.getUser().isMemberOf('Group X'))&&(current.sys_created_by.isMemberOf('Group X'))){
answer = true;
}

 

Basically, is there a way of asking the above in a simple statement?

The acl should allow read access if the current logged in user is a member of group x, and they are trying to read a ticket created by another user who is also a member of group x

 

Thanks 

2 REPLIES 2

SatyakiBose
Mega Sage

Community Alums
Not applicable

Try 

 

gs.getUser().getUserByID(current.sys_created_by).isMemberOf(<YOUR GROUP HERE>)

 

 

PS. The sys_create_by is not a reference field i believe...you will need to get the relevant user by using getUserByName or similar - check the docs for available methods