How to addOrquery in client script?

manita_singh
Kilo Explorer

var rel = new GlideRecord('cmdb_rel_ci');

rel.addQuery('parent','IN',device);

//Below line of code i want to add as OR query, addOrQuery is giving a onchange script error : addORQuery not defined function

rel.addOrQuery('child','IN',device);

** Requirement is to fetch all related CI of the Device CI   which can be either a Parent or a Child in the cmdb_rel_ci table


var rel = new GlideRecord('cmdb_rel_ci');

  rel.addQuery('parent','IN',device);

  //rel.addOrQuery('child','IN',device);

  rel.query();

  while (rel.next())

  {

  var ci = new GlideRecord('cmdb_ci');

  ci.addQuery('u_ci_type','Service');

  var child1 = rel.child; // this is fetching me only CI with "Depends on" relationship type, i want all relations of that CI

  child2.push(child1);

  //service = child1;

  //alert(child2);

  }

3 REPLIES 3

Deepak Ingale1
Mega Sage

http://wiki.servicenow.com/index.php?title=GlideAjax#gsc.tab=0



GlideRecords are server side calls.


If you want to achieve this from client scripts, user GlideAjax and Script Includes


Anurag Tripathi
Mega Patron
Mega Patron

hi Manita,



You can use this


var rel = new GlideRecord('cmdb_rel_ci');


rel.addEncodedQuery('parentIN'+device+'^ORchildIN'+device);


-Anurag

TJW2
Mega Guru

Best Practice is to put this into a Script Include and use a GlideAjax.


See WIKI article for coding an OR Query : http://wiki.servicenow.com/index.php?title=Scripting_in_Business_Rules#Scripting_an_OR_Condition&gsc...