- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-19-2022 06:33 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-19-2022 11:16 AM
From the client-side, you will have access to the g_user object. The methods which might help you are:
- hasRole
- hasRoleExactly
Here's some links which might help you.
https://servicenowguru.com/scripting/user-object-cheat-sheet/
https://developer.servicenow.com/dev.do#!/reference/api/quebec/client/c_GlideUserAPI?navFilter=glideuser
Otherwise, you will need to do a GlideAjax call or use g_scratchpad to make it available from the server-side to the client-side.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-20-2022 02:23 AM
Glad to help your here. If you have a follow up query then let me know else please mark my answer as correct and close this thread for others.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-20-2022 08:46 PM
Hi,
//onChange Client Script
if (newValue) {
var ga = new GlideAjax('getRoles');
ga.addParam('sysparm_name', 'getCallerRole');
ga.addParam('sysparm_caller_id', newValue);
ga.getXMLAnswer(getRoles);
}
function getRoles(response) {
var answer = response;
alert(answer);
}
Script Include
var getRoles = Class.create();
getRoles.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getCallerRole: function() {
var getCaller = this.getParameter('sysparm_caller_id');
return gs.getUser().getUserByID(getCaller).getRoles();;
},
type: 'getRoles'
});