function gld_hasRoleExactly(role) {
var au = new ArrayUtil();
var roles = gs.getSession().getRoles() + '';
var roleArray = roles.split(",");
var isAuthorized = au.contains(roleArray, role);
return isAuthorized;
}//courtesy of https://joshneri.us/serverside-hasroleexactly-in-servicenow/
var au = new ArrayUtil();
var roles = gs.getSession().getRoles() + '';
var roleArray = roles.split(",");
var isAuthorized = au.contains(roleArray, role);
return isAuthorized;
}//courtesy of https://joshneri.us/serverside-hasroleexactly-in-servicenow/
Also with javascripts .includes()
ReplyDeletefunction gld_hasRoleExactly(role) {
return gs.getSession().getRoles().includes(role);
}
gs.print(gld_hasRoleExactly('itil')); //false
gs.print(gld_hasRoleExactly('admin')); //true
cheers Max. See you in Vegas?
Delete