- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2024 05:47 AM - edited 02-26-2024 05:47 AM
Hi All,
We have a UI action on enhancement form, I have written the below script to check the related list test cases on the enhancement record.
requirement is to check the test cases status, the Enhancement should go into deployment state only if all the test cases linked to the record are in passed state. But with the below script it is checking only one test case. means even if we have multiple test cases without passed state it is moving further.
var gr = new GlideRecord('tm_test_case_instance');
gr.addQuery('parent', current.sys_id);
gr.addQuery('execution_status', 'passed');
gr.query();
while (gr.next()) {
current.state = '10';
current.update();
action.setRedirectURL(current);
}
Please assist.
Thanks & Regards.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2024 05:50 AM - edited 02-26-2024 05:58 AM
Hi @Joshuu
Update your script as below:
var totalCOunt = 0;
var passedCount = 0;
var gr = new GlideAggregate('tm_test_case_instance');
gr.addAggregate("COUNT");
gr.addQuery('parent', current.sys_id);
gr.addQuery('execution_status', 'passed');
gr.query();
if(gr.next()) {
totalCOunt = gr.getAggregate("COUNT");
}
}
var gr1 = new GlideAggregate('tm_test_case_instance');
gr1.addAggregate("COUNT");
gr1.addQuery('parent', current.sys_id);
gr1.query();
if(gr1.next()) {
passedCount = gr1.getAggregate("COUNT");
}
}
if(passedCount ==totalCOunt ){
current.state = '10';
current.update();
action.setRedirectURL(current);
}
Aman Kumar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2024 05:50 AM - edited 02-26-2024 05:58 AM
Hi @Joshuu
Update your script as below:
var totalCOunt = 0;
var passedCount = 0;
var gr = new GlideAggregate('tm_test_case_instance');
gr.addAggregate("COUNT");
gr.addQuery('parent', current.sys_id);
gr.addQuery('execution_status', 'passed');
gr.query();
if(gr.next()) {
totalCOunt = gr.getAggregate("COUNT");
}
}
var gr1 = new GlideAggregate('tm_test_case_instance');
gr1.addAggregate("COUNT");
gr1.addQuery('parent', current.sys_id);
gr1.query();
if(gr1.next()) {
passedCount = gr1.getAggregate("COUNT");
}
}
if(passedCount ==totalCOunt ){
current.state = '10';
current.update();
action.setRedirectURL(current);
}
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2024 05:54 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2024 05:58 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2024 06:22 AM