gr.get() and gr.addQuery()

Shraddha desai
Tera Contributor

What is the use of gr.get() and gr.addQuery() ?

2 REPLIES 2

Ionut Carp
Giga Sage

Hi,

The ‘get’ method is a great way to return a single record when you know the sys_id of that record.

Can also be used in Client scripts and UI policies IF YOU ARE GETTING A RECORD BY SYS_ID.
var gr = new GlideRecord('incident');
gr.get(sys_id_of_record_here);
//Do something with the record returned
if(gr.category == 'software'){
gs.log('Category is ' + gr.category);
}

 

The "addQuery" method will help you to add conditions on a query. Is like an "AND" condition. Practically, using this condition you will obtain a list of records which are complying to the condition.

You can read more about query and conditions here

Please mark my response helpful and correct if solved your issue.

 

Cheers,

Ionut

palanikumar
Mega Sage

gr.get - Retrieve a specific record from GlideRecord Object

gr.addQuery - Build query to the GlideRecord Object

Refer the below URL for More details

https://developer.servicenow.com/dev.do#!/reference/api/rome/server/no-namespace/c_GlideRecordScoped...

https://developer.servicenow.com/dev.do#!/reference/api/rome/server/no-namespace/c_GlideRecordScoped...

Thank you,
Palani