The CreatorCon Call for Content is officially open! Get started 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

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);


test.JPG




Now my result shows this.. i think somthing wrong with split



my functions are



client



function onChange(control, oldValue, newValue, isLoading, isTemplate) {


    if (isLoading || newValue === '') {


          return;


    }



  var gaj=new GlideAjax('HelloMan');


  gaj.addParam('sysparm_name','helloman');


// var ab_data=g_form.getDisplayBox('business_service').value;


  var ab_data=g_form.getValue('business_service');


  gaj.addParam('sysparm_business_service',ab_data);


  gaj.getXML(HelloManparse);



  function HelloManparse(response)


  {


  var answer = response.responseXML.documentElement.getAttribute("answer");


  var arr = answer.split(",").toString();


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


  {


  g_form.addInfoMessage("\nvalue is: " + arr[i]);




              }



  }


}



server



var HelloMan = Class.create();


HelloMan.prototype = Object.extendsObject(AbstractAjaxProcessor, {



  helloman : function(){


  var parentId = this.getParameter('sysparm_business_service');


  var childList = [];


  var rel = new GlideRecord('cmdb_rel_ci');


// rel.addQuery('parent.name','=', parentId);


  rel.addQuery('parent', parentId);


  rel.query();


  while (rel.next()) {


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


  childList.push(rel.child.name);


  }


  return childList.join(",");


  }




});


It worked thanks Chuck.. thanks a ton. I was wrongly dot walking.. its great your solution worked perfect


Thanks a ton


but one more problem the last value seems to be empty. may b because of split


Its working thanks.. thanks a lot. i have been struggling to make it