- 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
10-01-2020 05:41 AM
Yes, see the accepted solution.