The CreatorCon Call for Content is officially open! Get started here.

Array returns "undefined".

Victor Ruiz
Tera Guru

Attempting to retrieve a list of CI's but the second Glide query returns undefined, what am I missing?

 

var appsArr = [];

var gr2 = new GlideRecord('task_ci');
gr2.addQuery('task', current.sys_id);
gr2.query();
while(gr2.next()){

appsArr.push(gr2.ci_item.toString());

}

var applications = [];

for(var i=0; i<appsArr.length; i++){

var gr = new GlideRecord('cmdb_rel_ci');
gr.addQuery('child',appsArr[i]);
gr.query();
gs.log(gr.parent); //RETURNS UNDEFINED
while(gr.next()) {

applications.push(gr.parent.toString());
}
}
current.addQuery('sys_id','IN',applications.toString());

 

 

20 REPLIES 20

You are absolutely welcome!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!