The CreatorCon Call for Content is officially open! Get started here.

how do I Impersonate using script in ATF? Service-Now Orlando release

Chandan7
Kilo Contributor

Why do the step config  'Impersonate' not work in ATF in Orlando release. I tried in some of the test, but the Client Test Runner's page become unresponsive during the run. Also, I have noticed when I use the step config 'Impersonate', there is a warning saying- Impersonating an existing user may cause unexpected behavior for this test. Avoid potential issues by adding a 'Create a User' step instead. If someone is not supposed to use this step config, then why do it exist in the list.
'Create a user' is not so flexible, while working on a instance where there are lot of customizations. 

Can somebody help me please. Its urgent. 

Also, how do I Impersonate using script in ATF?

13 REPLIES 13

Hi Chandan,

Got it; Yes you are correct you can only set first name, last name, roles, groups for that user

so you can do this:

1) open the newly created user record using Open an Existing Record step and pass the sys_id of the previous step i.e. create user

2) set whatever fields you want as part of testing and then continue the testing

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

 

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

Hi,

Is there any update on this? Is this question resolved or you need some more assistance.

Please consider marking appropriate reply as Correct & 👍Helpful.

Regards
Ankur

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

can you try?

if (gr1.next()) {
var user_sysid = gr1.getUniqueValue();
outputs.u_user = user_sysid;

//Impersonate
gs.getSession().impersonate(user_sysid);
// gs.getSession().impersonate(outputs.u_user);
 

 


Please mark my response as correct and helpful if it helped solved your question.
-Thanks

Hi Prateek, 

    Just now, I tried that. But it did not impersonate the newly created user. The execution moved to next step with already logged in user, and after that progress bar didnot move.

Can you try to split them into two steps.

  1. User creation
  2. Impersonation

See if that helps.


Please mark my response as correct and helpful if it helped solved your question.
-Thanks