Report on sys_atf_test_suite_result table

PranjalSrvst
Tera Contributor

Hello Everyone,

I'm creating a report on the sys_atf_test_suite_result table. The issue is that every Test Suite execution creates a new record, so the report shows multiple records for the same Test Suite.

My requirement is to schedule a Test Suite to run weekly and have the report display only the latest execution result for each Test Suite.

For example, if the Incident Management Test Suite has multiple execution records, the report should show only the most recent one.

Has anyone achieved this in ServiceNow? Any suggestions would be appreciated.

 

pranjalsrvs_0-1783397310763.png

 

MaheshG95462175
Tera Contributor

Reports (classic or Data Visualization) don't natively support "latest row per group" logic you'd need to shape the data first. The cleanest approach:

1. Add a boolean field to sys_atf_test_suite_result, e.g. u_is_latest.

2. Create a Business Rule (after insert) on that table:
(function executeRule(current, previous) {
var prev = new GlideRecord('sys_atf_test_suite_result');
prev.addQuery('test_suite', current.test_suite);
prev.addQuery('sys_id', '!=', current.sys_id);
prev.addQuery('u_is_latest', true);
prev.query();
while (prev.next()) {
prev.u_is_latest = false;
prev.update();
}
current.u_is_latest = true;
})(current, previous);

3.Build your report/filter with a condition of u_is_latest = true now it always shows just the most recent run per suite.