How to validate Single Record in Automated Testing Framework ATF

Swapnil
Tera Contributor

Hi Folks. I have recently started working with ATF. I have a requirement where I have to validate if there is only one record present in sys_journal_table. The challenge is you can query, open and validate the record but Assertion is "there is atleast one record present" OR "No record Present" , I have to assert and validate if there is only one record is present with certain conditions. Please Assist. I've tried running server side script as well, attaching script below:


2 REPLIES 2

Utpal Dutta
Tera Guru

Hi Swapnil,

You don't need to run any server side script for this. You can just do a 'Record Query' on the table with filters to filter the record. This Record Query step will only pass when a record matching your filter condition is found in the table else this Record Query step will fail.

Let me know if you need more help regarding this!

 

Thanks,

Utpal

Hi Utpal , 

this is not case here. I do not have to validate if there is record present or not. I need to validate that when conditions are put there should only be one record present. Like I said in Record query feature we only have two assertions "there is atleast one record present" OR "No record Present" , I have to assert and validate if there is only one record present. There should not be two record present with those conditions in table, that is what I am trying to achieve. Please assist . Below is the script just in case if you would need to have look .

 

 

 

var grm = new GlideRecord('sc_req_item');
var ritm = grm.get(steps(14f0deed97dba5547e9f3737f053af22).record_id);
var gr = new GlideAggregate('sys_journal_field');
gr.addQuery("value", ritm);
gr.addEncodedQuery('valueLIKEIIQ Access Request ID');
gr.addAggregate('COUNT');
gr.query();
var journal = 0;
if (gr.next()) {
journal = gr.getAggregate('COUNT');
}

 

if (journal == 1) {

stepResult.setOutputMessage = journal;

 

return true;
} else {

 

return false;
}