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

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

what is the exact steps you configured so far?

What are you trying to achieve in the step which is failing?

regards
Ankur

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

Hi @Ankur Bawiskar  

 

The steps I've configured so far are Creating a User and Navigating to a module which goes to the 'sys_user' table. For the step where it's failing 'Record Query', I'm wanting the step to gather the results from the following query:

active=true^u_employment_type=Physical Access Only^locked_out=false^RLQUERYx_snc_acc_entitle_user_account.user,<1^ENDRLQUERY

 

What I want to see is that if there are no users in the 'sys_user' table, then the ATF test passes. However, if any users do appear, then the ATF test fails.

Hi,

Can you share test steps you configured so far?

Regards
Ankur

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

Sure. My steps are attached. I'm wanting to get that query applied in step 3.