Skip to content

Instantly share code, notes, and snippets.

@iamwill
Last active October 24, 2025 05:43
Show Gist options
  • Save iamwill/b545331f2934d6239ba2b85f3c1cf9ec to your computer and use it in GitHub Desktop.
Save iamwill/b545331f2934d6239ba2b85f3c1cf9ec to your computer and use it in GitHub Desktop.
GlideRecord cheatsheet

GlideRecord Cheat Sheet

var gr = new GlideRecord('incident');

Is Valid?

.isValid() Check if current table is valid

.isEncodedQueryValid(String queryString) Check if queryString is valid

.isValidField(String columnName) Check if columnName is valid

.isValidRecord() Check if current record is valid

Has Access?

.canCreate() Can the user create a record in this table?

.canDelete() Can the user delete from this table?

.canRead() Can the user read from this table?

.canWrite() Can the user write to this table?

Deleting Records

.deleteMultiple() Deletes multiple records that satisfy the query condition. Do not use deleteMultiple() on tables with currency fields. Always delete each record individually.

var gr = new GlideRecord('incident')
gr.addQuery('active','false'); // delete all inactive incidents
gr.deleteMultiple();

.deleteRecord() Deletes the current record.

var gr = new GlideRecord('incident')
if (gr.get('99ebb4156fa831005be8883e6b3ee4b9'))
    gr.deleteRecord();
}

addQuery operators

Number fields:

  • =
  • !=
  • =

  • <
  • <=

String fields:

  • =
  • !=
  • IN
  • NOT IN
  • STARTSWITH
  • ENDSWITH
  • CONTAINS
  • DOES NOT CONTAIN
  • INSTANCEOF

From:

https://developer.servicenow.com/app.do#!/api_doc?v=madrid&id=c_GlideRecordScopedAPI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment