gs,getUserId returns wrong value in ACL while impersonating

OmniaM
Tera Contributor

Hello Guys,

 

I'm trying to check if the Requested by user is the same loggedIn user so i checked this in the ACL but gs.getUserID returns my ID not the impersonated user 

here's the code : 

(function () {
  var userId = gs.getUserID();
  var internalUserId = current.getValue('internal_user'); // sys_id string (safe)

//var imp = new GlideImpersonate();

  // TEMP debug (remove after testing)
//   gs.info('[NEW ACL by Mark] internal_user(sys_id)=' + internalUserId +
//           ' internal_user(display)=' + current.getDisplayValue('internal_user') +
//           ' currentUser=' + userId);

  answer = (gs.hasRole('sn_retail.associate_fulfiller') ||internalUserId == userId);
})();
 
Do you know how to resolve this???
2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@OmniaM 

don't try to test ACL with impersonation.

Try to clear instance cache and then impersonate

Did you check with actual user?

it should give the correct logged in user sysId

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

Hello @Ankur Bawiskar ,

thanks for your support.

but i did this already and still get my ID instead of the impersonated user so i just need to check if the cases created by person is the same loggedIn user, is there anyway?