Correct syntax for ACL checking group membership

Lon Landry4
Mega Sage

This is for Utah release (I have an all config version in Washington DC that works fine).

I have tried the following four ways


  1. var user = gs.getUser();
    answer = user.isMemberOf('IhaveTriedGroupSysID&GroupNameHere'); 

  2. answer = 
    gs.getUser().isMemberOf('IhaveTriedGroupSysID&GroupNameHere');

  3. gs.getUser().getUserByID(current.user).isMemberOf('IhaveTriedGroupSysID&GroupNameHere');
    //I have tried with and without wrapping sys_id or group name in quotes

  4. if
    (gs.getUser().isMemberOf('MyGroupName')) {
      answer = true;
    } else { answer = false;}
     
    Any ideas?
1 ACCEPTED SOLUTION

James Chun
Kilo Patron

Hey @Lon Landry4,

 

The first option should work for both cases - using the group name or its sys_id

e.g.

 

 

var user = gs.getUser();
answer = user.isMemberOf('cfcbad03d711110050f5edcb9e61038f');
answer = user.isMemberOf('Team Development Code Reviewers'); //both works

 

 
Are you certain it's the script that is causing the issue?
Maybe you have another condition (such as role) or another ACL that is interfering with your ACL?
 
FYI, from Vancouver, you can use what's called Security Attribute within your ACL - https://docs.servicenow.com/bundle/washingtondc-platform-security/page/administer/contextual-securit...
 
Cheers
 

View solution in original post

7 REPLIES 7

James Chun
Kilo Patron

Hey @Lon Landry4,

 

The first option should work for both cases - using the group name or its sys_id

e.g.

 

 

var user = gs.getUser();
answer = user.isMemberOf('cfcbad03d711110050f5edcb9e61038f');
answer = user.isMemberOf('Team Development Code Reviewers'); //both works

 

 
Are you certain it's the script that is causing the issue?
Maybe you have another condition (such as role) or another ACL that is interfering with your ACL?
 
FYI, from Vancouver, you can use what's called Security Attribute within your ACL - https://docs.servicenow.com/bundle/washingtondc-platform-security/page/administer/contextual-securit...
 
Cheers
 

Neither option above works. No messages whatsoever, even if I write in an gs.addInfoMessage(answer);

Security Attribute within your ACL Rocks!
But, this needs to go into a Utah instance...

Can you share a screenshot of the entire ACL and what you are trying to do with it?

Also, have you done some ACL debugging?