Checking users group membership via an acl

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2023 09:22 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2023 09:37 AM
Hello @Cirrus
You might want to check this post - https://www.servicenow.com/community/developer-forum/acl-check-for-group/m-p/1604133

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2023 09:43 AM - edited 02-20-2023 09:50 AM
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