We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

How to fetch the output of previous step into next step in ATF

khareakshay
Tera Contributor

Hi
I am trying to verify that the domain of RITM created is same as that of catlog item. For this I have used record query step to find the RITM created and in the next step I am using server script as below and I am getting undefined for "ritmSysId" and "ATF steps object". How to resolve this

(function(outputs, steps, params, stepResult, assertEqual) {
    // add test script here
    gs.info("ATF Steps Object:"+ JSON.stringify(steps));
var ritmSysId = steps.Record_Query.first_record;
gs.info("RITM Sys Id:" + ritmSysId);

var ritm = new GlideRecord('sc_req_item');
if(!ritm.get(ritmSysId)){
    outputs.result=false;
    outputs.message="RITM not found";
    return false;
}

var catItem = new GlideRecord('sc_cat_item');
catItem.get(item.cat_item);

if(ritm.sys_domain == catItem.sys_domain){
    //outputs.result = true;
    //outputs.message = "Pass-same domain";
    return true;
}else{
    //outputs.result = false;
    //outputs.message = "Fail - Domains do not match";
    return false;
}

})(outputs, steps, params, stepResult, assertEqual);
3 REPLIES 3

khareakshay
Tera Contributor

I have updated the script with following. It is giving me correct RITM sysId but still it is returning false. I have validated that domain are same at backend

(function(outputs, steps, params, stepResult, assertEqual) {
    // add test script here
    gs.info("ATF Steps Object:"+ JSON.stringify(steps));
var ritmSysId = steps('01337a7193c14f503912f9f7dd03d6af').first_record;
gs.info("RITM Sys Id:" + ritmSysId);

var ritm = new GlideRecord('sc_req_item');
if(!ritm.get(ritmSysId)){
    outputs.result=false;
    outputs.message="RITM not found";
    return false;
}

var catItem = new GlideRecord('sc_cat_item');
catItem.get(item.cat_item);

if(ritm.sys_domain == catItem.sys_domain){
    //outputs.result = true;
    //outputs.message = "Pass-same domain";
    return true;
}else{
    //outputs.result = false;
    //outputs.message = "Fail - Domains do not match";
    return false;
}

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

@khareakshay 

share your complete test steps screenshots

Also the user which you are using for running the test is belonging to which domain?

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

Tanushree Maiti
Tera Patron

Hi @khareakshay 

 

refer : Passing data from one automated test step to another 

 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti