Impersonation from server-side script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
26m ago
I am trying to create a custom server-side step config to add groups/roles to an existing user created part of previous steps or reusable tests, and it seems the executing user should have admin or test designer permissions to do groups/roles to users.
So, I did like below, and it is not working or group/roles getting added. Is there any additional points to consider here or missing anything? Appreciate any inputs.
//Get current user
var current_user = gs.getUserID();
//Impersonate user with permissions to alter user record
gs.getSession().impersonate(inputs.admin_or_test_designer_user);
//My Groups addition code
//Impersonate back to original condition
gs.getSession().impersonate(current_user);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
19m ago
is this for ATF?
if yes then why to do impersonation in script?
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
15m ago
@Ankur Bawiskar Like I mentioned, the current user should have required permissions to add groups/roles to the user. So, trying to impersonate as an admin user, add the group/roles, and continue to the next step. Hope it helps to understand.