- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
I have seen few questions around how to set multiple values dynamically to list collector variable in ATF for catalog item or record producer.
Consider you have a catalog item with 2 variables:
1) Requester: Auto-fills with logged in user
2) Users Group: It should populate 5 active groups from Groups table.
In order to keep ATF testing dynamic we should not "hard-code" specific groups in our testing.
There could be a scenario that the static groups which are selected in the ATF may get deactivated in future.
This will lead the ATF Test Step to fail. So we would like to query the group table for active groups.
Below approach can be used:
1) Use "Run Server Side Validation Script" Test Step to query the groups table, push the Groups sys_id in an array and store them in the output variable. The output variable 'table' should be set to sys_user_group and the output variable 'record_id' should be set to the array of group sysIds
2) While setting the variable values using "Set variable values" step the output from above step can be used as an input to the variable value
Note: Ensure you use the "Run Server Side Validation Script" test step before the "Set Variable Values (SP)" step
Script for "Run Server Side Validation Script:
(function(outputs, steps, stepResult, assertEqual) {
// add test script here
var arr = [];
var grMember = new GlideRecord('sys_user_group');
grMember.addActiveQuery();
grMember.setLimit(5);
grMember.query();
while(grMember.next()){
arr.push(grMember.getUniqueValue());
}
outputs.table = 'sys_user_group';
outputs.record_id = arr.toString();
stepResult.setOutputMessage("Successfully collected active groups " + arr.toString());
stepResult.setSuccess();
return true;
})(outputs, steps, stepResult, assertEqual);
Screenshots below:
ATF Test & Test Steps
Run Server Side Script:
Assigning Output of Previous Step as Input to Variable:
Output for test when running in portal view:
Output for test when running in native view:
Thanks for reading the blog and do provide your inputs/suggestions if any.
Hope you find this article helpful. Don’t forget to Mark it Helpful, Bookmark.
Thanks,
Ankur Bawiskar
- 4,834 Views
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.