Skip to content

Instantly share code, notes, and snippets.

@cmcdevitt
Created September 1, 2022 18:42
Show Gist options
  • Select an option

  • Save cmcdevitt/564e4f0e3cb02aa05a0d46d407ca2cc7 to your computer and use it in GitHub Desktop.

Select an option

Save cmcdevitt/564e4f0e3cb02aa05a0d46d407ca2cc7 to your computer and use it in GitHub Desktop.
hasRoleExactely Server Side
// 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