customize Impersonation dialog box

KrishnaMohan
Giga Sage

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.

KrishnaMohan_0-1678100779791.png

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

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@KrishnaMohan 

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"

AnkurBawiskar_0-1678104225837.png

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

hi @Ankur Bawiskar 

 

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'
};