How to addOrquery in client script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2015 03:03 AM
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);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2015 03:17 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2015 03:34 AM
hi Manita,
You can use this
var rel = new GlideRecord('cmdb_rel_ci');
rel.addEncodedQuery('parentIN'+device+'^ORchildIN'+device);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2015 06:19 AM
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...