- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2018 03:44 PM
Running code below in a client script on form, not on a record producer. The user has no Department or Division role, but does have a Unit role.
alert ("Starting");
var gUser = g_user.userID;
var Reviewer = g_user.hasRoles('Department','Division');
var personalRole = g_user.hasRole('Unit');
alert ("User: " + gUser + " Reviewer: " + Reviewer + " Unit Role :" + personalRole);
The last alert is showing the correct user (when I impersonate them).
Reviewer is ALWAYS true, even though the user doesn't have those roles.
The personalRole is correct and has been tested for both true and false conditions.
Any idea why it isn't returning false for Reviewer?
I've confirmed the user doesn't have either role (twice).
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2018 03:53 PM
g_user.hasRoles(); I believe it evaluates if current user has ANY role whether it's 'Department','Division' or ANY other role. If user has any role other than 'Department','Division' roles it should return true.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2018 03:53 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2018 03:56 PM
Ah, got it, totally did not understand that. Probably should name the method "hasAnyRole'.
Found this works for what I was trying to accomplish.
if (g_user.hasRoleExactly('Department') || g_user.hasRoleExactly('Division') || g_user.hasRoleExactly('Enterprise') ) {
reviewer = true;
} else {
reviewer = false;
}
Thank you for the quick reply.
-G

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2018 03:59 PM
Did you try hasRoleExactly with multiple roles? Both Department and Unit role?
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2018 04:01 PM
yes, you can try multiple roles with hasRoleExactly().