ATF - run server side side script issue
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2024 01:12 AM - edited 09-17-2024 03:09 AM
Hi,
I want to run a server side script to display only the records that are created now. I tried but the script is not working it is showing all the records present in the form but I only want the ones to display which are created now using atf steps.
The script used :
(function() {
// Define the expected outcome (change this value according to your test case)
var expectedRowCount = 4; // Modify this value as per your expected row count
// Create a GlideRecord object for the ATF table
var gr = new GlideRecord('u_ssb_change_request'); // Replace with the appropriate ATF table
// Add query to fetch records created today
gr.addQuery('sys_created_on', '>=', gs.beginningOfToday());
gr.addQuery('sys_created_on', '<=', gs.endOfToday());
// Log a message to confirm the query is running
gs.info('Running query to fetch ATF records created today...');
// Execute the query
gr.query();
// Get the actual row count
var actualRowCount = gr.getRowCount();
// Log the actual row count
gs.info('Actual row count retrieved: ' + actualRowCount);
// Assert against the expected row count
if (actualRowCount === expectedRowCount) {
gs.info('Test passed: The row count matches the expected outcome (' + expectedRowCount + ').');
} else {
gs.error('Test failed: Expected ' + expectedRowCount + ', but found ' + actualRowCount + ' records.');
}
// Additional debug info (in case query fails)
if (!gr.hasNext()) {
gs.warn('No records found matching the query for today. Please check the query criteria.');
}
})();
Thanks,
Tiasha
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2024 06:44 AM
Hi @tiasha123 , if we are able to do it with the Record Query and applying filters, then why do you want to achieve this with the script? Is there anything specific you want to achieve?