ATF - Impersonating the Technical Owner from a Catalog item record

luiscarrion
Tera Contributor

Hi, I'm trying to enhance an ATF test not hard coding the impersonation of the technical owner for a Catalog Item, since this may change and make the test fail. At the moment I'm impersonating a specific user.

Basically I want to pick the technical owner field value: 'owner' from a record in the sc_cat_item table and impersonate it. I have tried several server side script steps I found in the community and other sources but nothing seems to work. 

5 REPLIES 5

Dr Atul G- LNG
Tera Patron

Hi @luiscarrion 

That’s not possible because it is ATF. We need to define which user should be used to run the test case, and we also need to inform the system which user is being impersonated.

*************************************************************************************************************
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/dratulgrover [ Connect for 1-1 Session]

****************************************************************************************************************

Tanushree Maiti
Tera Patron

Hi @luiscarrion 

 

Refer:

 

KB0782883 ATF Failure: Error Impersonating the User 

https://www.servicenow.com/community/developer-forum/dynamically-retrieving-the-approver-user-in-atf...

https://www.servicenow.com/community/developer-forum/atf-create-a-user-set-other-user-field-values/m...

 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti

Shaqeel
Mega Sage

Hi @luiscarrion 

 

Try following steps:

1. Submit request.

2. Record Query on sysapproval_approver table and add filter such as created today. and make sure before hand that in approval table created is selected as below.

Shaqeel_0-1781170941772.png

 

3. Use Impersonate >>Record query.

 

 

This would solve your issue.

 


***********************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting "Accept as Solution" and " Helpful." This action benefits both the community and me.

***********************************************************************************************************************





Regards

Shaqeel

luiscarrion
Tera Contributor

hi, thank you all for your inputs. @Shaqeel I tried your solution but I'm not able to impersonate the approver from the record query, or at least I don't see any way of pointing to the approver sys_id from the Impersonation step, using the pill it takes the approval record but not the approver (user). Thank you.