The CreatorCon Call for Content is officially open! Get started here.

Is there a "deleteQuery" or "removeQuery" to remove a GlideRecord query condition?

DarkAvenger
Kilo Expert

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?

1 REPLY 1

justin_drysdale
Mega Guru

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.