Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

how to query cmdb_rel_ci table to get parent and child value using glide record

Abhinab Achary1
Tera Guru

Hi All,

I want to query the child value based on parent value in table cmdb_rel_ci

How can this be done

Thanks,

Abhi

1 ACCEPTED SOLUTION

Thanks. I didn't see that you changed the childList.push() line. You cannot dot-walk inside a getValue() call. IN your case, use this.



childList.push(rel.child.name);


View solution in original post

24 REPLIES 24

Chuck Tomasi
Tera Patron

Hi Abhi,



It would look something like this:



var parentId = 'some sys_id of a CI';


var childList = [];


var rel = new GlideRecord('cmdb_rel_ci');


rel.addQuery('parent', parentId);


rel.query();



while (rel.next()) {


        childList.push(rel.getValue('child'));


}



// Now you have an array of sys_ids of the child records


can i write this under script include


Yes, the above snippet is server side code.



Script includes


but the childLIST is an array , now how can this be passed to the client side