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

ATF Create A User: Set other User Field Values

jmiskey
Kilo Sage

So, we have read where it is better to use the "Create a User" Step instead of the "Impersonate a User" step (especially to protect against the situation where a user may become inactive.

We see where you can select Groups/Roles for users when using "Create a User", but what about other "User" related-fields?  We have certain Catalog Items that have Criteria that make them only available based on which Department a User is in.  But we do not know how we can set the Department field when using the "Create a User" step.

Likewise, some of our Catalog Items have approvals that are based on the User's Manager, so I think we need a way to set the User's Manager when we Create a User, but do not see how we can set a Manager when we use "Create a User".

So how can we set things like "Department" and "Manager" when we use the "Create a User" step in Automated Testing Framework Tests when Testing Catalog Items (for our Service Portal)?

Thanks

1 ACCEPTED SOLUTION

Brad Tilton
ServiceNow Employee
ServiceNow Employee

I'm not sure it's covered in the ATF Fundamentals course, but that is a pretty thorough 8-hour self-paced training course and a great place to start. It is also mentioned, though not with an example, in the ATF webinar and best practices links you can find at this ATF Resources post.

For your use case it would look like:

ATF Test Step 1: Use the record query step to lookup a user that meets the specifications you're looking for (has a department or manager, etc.)

ATF Test Step 2: Impersonate step where you impersonate the user found in the record query step 1.

I've been meaning to write up a detailed post on dynamic selection, but in the meantime hopefully this helps. The ATF Resources post I linked to has a couple of different training links I would definitely work through.

View solution in original post

16 REPLIES 16

I just tested by impersonating after updating department and it worked. 🙂 

You could go Create User (but not impersonate) --> Update department --> Impersonate, but I think just doing Record Lookup --> Impersonate is a little simpler in this case. The test will also run quicker as you're not doing a create and update before running the impersonation.

That shouldn't be necessary, should it?  On the "Create a User" step, there is a Check Box for "Impersonate this User" that I have selected.  So it should already be doing this, right?

And if you are not impersonating this user, I am not sure how you would do the next step, the Record Update step, and update this User's record.

Brad Tilton
ServiceNow Employee
ServiceNow Employee

If you uncheck the impersonate user checkbox then it will run as the system and you should be able to update the user record. I think the point is that if you're going this route you probably need to update the user record before impersonating.

Yes, you are right.  When I made this change, this works also.

Thank you.