- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2020 06:15 AM
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
Solved! Go to Solution.
- Labels:
-
Automated Test Framework

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2020 01:14 PM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2020 06:52 AM
I think you've got a couple of options here:
- Use a Record Update step after your create a user step to update the fields on the user record with values.
I would probably also combine this with a record lookup step where you're looking up a department value based on the name so you don't run into a situation where the department sys_ids are off across instances. - Your other option would be to use dynamic selection. In this scenario you would use a record lookup step to search for a user record that meets your criteria and then impersonate that user. That way you're not hardcoding a user and you're introducing some randomness into the testing process.
While we do recommend using the Create User step to start a test, it's not always the right choice.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2020 08:17 AM
Thanks for the reply Brad.
That makes sense. For some reason, it did not work for me, and I am not sure if it because I am doing something wrong.
I have a Record Produce that is only available for users in certain departments. The User Criteria looks like this:
If I impersonate a User in the "Print" department, I am able to successfully create an ATF test that works as expected.
So I tried creating the same steps, but with using the "Create User" and "Record Update" Steps instead, and it did not appear to work. Here are what those steps looked like:
And it failed. The failure message it gave me was on Step 3 and it said "FAILURE: Failed to open Record Producer. Either you don't have access to the Record Producer or g_form is not defined". So, it seems like it didn't seem to recognize that the user met the User Criteria of being in the "Print" department and should have access to the Form.
Is there something that has to be done first to get that to "Update" before opening the Form/Record Producer?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2020 11:28 AM
Hmm...I wonder if you'd need to either do the impersonation again to pick up the field change and get the security to evaluate. It also might be that the form is loading before the update happens and you need a server script step with gs.sleep to pause the test while the update takes place.
I would explore the dynamic selection route, as that seems simpler for this use case.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2020 12:06 PM
I am intrigued by this dynamic selection option, but don't know much about it, and my keyword searches haven't been that fruitful. Can you point me to any good articles on how to use this?