Is there a "deleteQuery" or "removeQuery" to remove a GlideRecord query condition?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2013 10:24 AM
Hi all
I need to build a GlideRecord query to check first one record from a table, and thereafter use information in that to retrieve another record.
My problem is that the query for the second record is different from the first.
Is there a way to clear the query condition I add using "addQuery"? Or do I need to reinstantiate the handle to the table?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2013 11:02 AM
You may nest/stack GlideRecords, just store them in a different variables.
Once you have what you need from the first Glide call, use it in your second Glide.
var s_user = new GlideRecord('sys_user');
s_user.addQuery("sys_id", 'ba349234....');
s_user.query();
while ( s_user.next() ) {
var name = s_user.name;
}
var asgn_asset = new GlideRecord("cmdb_ci_printer");
asgn_asset.addQuery("assigned_to", name);
asgn_asset.query();
if ( asgn_asset.next() ) {
alert("asset found!");
}
There is also a shorthand way to call Glides but i don't use it too often.