- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2020 07:39 AM
In building out our ATFs, I have come across something I am not sure how to do. In some of our Catalog Items, we allow them to enter multiple users. When creating an ATF, usually when setting the variable values, when setting a field that allow multiple entries, you separate them with a comma. If we were selecting specific users from the user table, this would work fine. However, in the interest of keeping our ATF testing dynamic, we do not wish to "hard-code" specific users in our testing. We would like to either query the user table for active users, or create users to use for testing.
So, in my test, I did one of each (Record Query to query active users and Create a User). It was my hope that then when I was populating my user field on my Catalog Item, I would be able to select each of these. But that does not appear to be the case. It looks like if you select a user from a previous step, there doesn't appear to be a way to select another user.
This is what it looks like (the first field is my user field):
So, is there any way to select multiple dynamic users in an ATF test on the 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
04-04-2020 01:43 AM
Hi,
I was able to set the values dynamically using Run Server Side Script
please update code as below in the script; see screenshot as well
Ensure you determine this and then open the catalog item and then set the values
(function(outputs, steps, stepResult, assertEqual) {
//set up array for output
var users = [];
// pull out first 2 active members of sys_user table
var gr = new GlideRecord('sys_user');
gr.addQuery('active','true');
gr.setLimit(2);
gr.query();
//build array of two users to output
while(gr.next()){
users.push(gr.getValue('sys_id'));
}
outputs.table = 'sys_user';
outputs.record_id = users.toString();
stepResult.setOutputMessage("Successfully collected users " + users.toString());
stepResult.setSuccess();
return true;
})(outputs, steps, stepResult, assertEqual);
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2020 09:29 AM
Hi,
Any update on this?
Can you mark my answer as ✅ correct, 👍 helpful if you were able to achieve the requirement. This enables other members to learn from this thread.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2020 05:51 AM
Sorry, I typically do not work over the weekends, so am just getting back to this now on Monday. Yes, that works, thank you very much.
It has kind of presented a new challenge though. After these transactions are submitted via the Service Portal, I am then continuing the ATF testing by working on them after the RITMs have been created. The first step in the Workflow is Manager approval. So I would need to dynamically impersonate the managers of those dynamic users we selected above in order to do the approvals. I have a feeling that is going to be another Server Side Script. Maybe we look up the Approver off of the RITMs that are created? Not really sure the best way to go about that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2020 08:24 AM
Hi,
you can have server side script and query the approval table for this RITM which got created in previous step and then determine the approver user; store in the record_id variable
you can then use that in impersonate step
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2020 01:23 PM
Got it. Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2020 02:30 AM
Hi,
You got solution for multiple dynamic users?