The CreatorCon Call for Content is officially open! Get started here.

ATF - run server side side script issue

tiasha123
Tera Contributor

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.');
    }
})();

 

tiasha123_0-1726560466523.png

 

Thanks,

Tiasha

5 REPLIES 5

Shaqeel
Mega Sage
Mega Sage

@tiasha123 

 

Can't you just open the table and apply filter there?

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting "Accept as Solution" and " Helpful." This action benefits both the community and me.

*************************************************************************************************************

 

 

Regards

Shaqeel


***********************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting "Accept as Solution" and " Helpful." This action benefits both the community and me.

***********************************************************************************************************************





Regards

Shaqeel

Hi @Shaqeel ,

 

Yes we can do that , but if theres a solution to do it using server side script , it would be very helpful.

@tiasha123 

 

This script of yours verify that a certain number of records were created in the u_ssb_change_request table on the current day.


***********************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting "Accept as Solution" and " Helpful." This action benefits both the community and me.

***********************************************************************************************************************





Regards

Shaqeel

but its showing all the records created till now. Its not limited to created "today".