Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

GlideRecord in servicenow examples

Bhujangi Gawal1
Tera Contributor

what is Glide Record with examples

2 REPLIES 2

Sai Kumar B
Mega Sage

Hi @Bhujangi Gawali 

The GlideRecord class is the way to interact with the ServiceNow database from a script.

You can do the below database operations using GlideRecord()

1.) Insert

2.) Update

3.) Delete

4.) Retrieval 

Below is the example of retrieving the record information 

For reference - https://developer.servicenow.com/dev.do#!/learn/learning-plans/quebec/new_to_servicenow/app_store_le...

https://developer.servicenow.com/dev.do#!/reference/api/quebec/server/c_GlideRecordScopedAPI

// 1. Create an object to store rows from a table
var myObj = new GlideRecord('incident');

// 2. Build query
myObj.addQuery('active', true);

// 3. Execute query 
myObj.query();

// 4. Process returned records
while(myObj.next()){
  //Logic you want to execute.  
  //Use myObj.field_name to reference record fields
}

Geoff_T
Mega Sage

Hi,

The developer docs can help:

https://developer.servicenow.com/dev.do#!/learn/learning-plans/rome/servicenow_application_developer/app_store_learnv2_scripting_rome_gliderecord

 

Also check this out:

https://servicenowguru.com/scripting/gliderecord-query-cheat-sheet/

 

Geoff