Created
September 1, 2022 18:42
-
-
Save cmcdevitt/564e4f0e3cb02aa05a0d46d407ca2cc7 to your computer and use it in GitHub Desktop.
hasRoleExactely Server Side
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://joshneri.us/serverside-hasroleexactly-in-servicenow/ | |
| function hasRoleExactly(role) { | |
| var au = new ArrayUtil(); | |
| var roles = gs.getSession().getRoles() + ''; | |
| var roleArray = roles.split(","); | |
| var isAuthorized = au.contains(roleArray, role); | |
| return isAuthorized; | |
| } | |
| //or maybe | |
| //https://community.servicenow.com/community?id=community_question&sys_id=d8edab96dbd67f80d58ea345ca96195e | |
| function hasRoleExactly(roleName){ | |
| if (gs.getSession().getRoles().toString().indexOf(roleName)>0){ | |
| return true; | |
| } else { | |
| return false; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment