How to add a query and related query from a Report into an ATF step

matthew_hughes
Kilo Sage

I'm trying to retrieve a query from a report for an ATF test I'm working on:

When I click on the number 80, it takes to the the list within the sys_user table where it contains a Related List condition, and from there I'm able to right click on the end of the filter and select 'Copy query':

However, what I'm wanting to do is use the query when I click on 'Copy query' and apply that within my ATF. i was just wondering if that is possible to do.

 

1 ACCEPTED SOLUTION

Hi @Ankur Bawiskar I've fixed it now by applying the following:

(function(outputs, steps, stepResult, assertEqual) {


    var gr = new GlideRecord('sys_user');
    gr.addQuery('active=true^u_employment_type=Physical Access Only^locked_out=false^RLQUERYx_snc_acc_entitle_user_account.user,<1^ENDRLQUERY');
    gr.query();
    var numUsers = gr.getRowCount();
    if (numUsers == 0) {
        stepResult.setOutputMessage("There are currently no Physcial Access Only user records that don't have a related account");
        return true; // pass the step
    } else {
        stepResult.setOutputMessage("There are affected Physcial Access Only user records that don't have a related account. They can be found in report 'Physical Access Users with no accounts ACTIVE not Locked out'");
        return false; // fail the step
    }

})(outputs, steps, stepResult, assertEqual);

View solution in original post

6 REPLIES 6

Hi,

Did you try to change the Assert type?

Asserting Test Success

regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar I've fixed it now by applying the following:

(function(outputs, steps, stepResult, assertEqual) {


    var gr = new GlideRecord('sys_user');
    gr.addQuery('active=true^u_employment_type=Physical Access Only^locked_out=false^RLQUERYx_snc_acc_entitle_user_account.user,<1^ENDRLQUERY');
    gr.query();
    var numUsers = gr.getRowCount();
    if (numUsers == 0) {
        stepResult.setOutputMessage("There are currently no Physcial Access Only user records that don't have a related account");
        return true; // pass the step
    } else {
        stepResult.setOutputMessage("There are affected Physcial Access Only user records that don't have a related account. They can be found in report 'Physical Access Users with no accounts ACTIVE not Locked out'");
        return false; // fail the step
    }

})(outputs, steps, stepResult, assertEqual);