customize Impersonation dialog box
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2023 03:16 AM
Hi,
I am working on impersonation restrict for groups. for that I used ImpersonateEvaluator script include and developed script based on requirements. It's working fine.
if we observe in the image, its stops the impersonation and showing message like bad request(400). instead of this message , how can I add customize message like example : - you don't have permissions.
Thanks,
KrishnaMohan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2023 04:04 AM
can you share your current script which you have updated in that script include?
I saw similar message in Messages table.
try creating a new record in messages table, with same key and value as "you don't have permissions"
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2023 05:02 AM - edited 03-06-2023 05:06 AM
thanks for your reply. please find the below code. also I created a new record in messages table with value
"you don't have permissions"
var ImpersonateEvaluator = Class.create();
ImpersonateEvaluator.prototype = {
initialize: function() {},
canImpersonate: function(currentUser, impersonatedUser) {
var isImpersonate = false;
var isAdmin = currentUser.hasRole('admin');
// return currentUser.isMemberOf('518fc91a1b32c1509b6987b7624bcba0');
if (isAdmin || this.groupsCanImpAny(currentUser)) {
return false;
} else if (this.groupsCanImpOnlyCustomers(currentUser, impersonatedUser)) {
//gs.addErrorMessage('Hello');
return true;
}
return false;
},
groupsCanImpAny: function(currentUser) {
var canImpAny = gs.getProperty('groups_impersonate_to_any').split(',');
for (var i in canImpAny) {
if (currentUser.isMemberOf(canImpAny[i]))
return true;
}
},
groupsCanImpOnlyCustomers: function(currentUser, impersonatedUser) {
var canImpCust = gs.getProperty('groups_impersonate_to_only_customers').split(',');
var isInternal = gs.getUser().getUserByID(impersonatedUser.getID()).getEmail().indexOf('opentext.com');
for (var i in canImpCust) {
if (currentUser.isMemberOf(canImpCust[i]) && (isInternal == -1))
return true;
}
},
type: 'ImpersonateEvaluator'
};