The get() method is ServiceNow's direct record retrieval by sys_id — it's equivalent to addQuery('sys_id', sysId) plus query() plus next(), but in a single call. The critical gotcha: get() returns false if the record doesn't exist or you lack read access, but it doesn't throw an error. Developers who skip the null check will access empty fields without realizing the record wasn't found.

When to use this

  • When you have a sys_id from a reference field, current record, or API response
  • When retrieving a parent record from a child record's reference field
  • When building utilities that need to load a specific record for processing
  • When you need to validate a record exists before performing operations on it

When NOT to use this

  • Don't use in client scripts — use GlideAjax to call a Script Include instead
  • Don't use in loops over multiple records — you'll create N+1 database queries
  • Don't use when you need multiple records from the same table — use addQuery() with IN operator instead
  • Don't use when you only need to check if a record exists — use GlideRecord.isValidRecord() for better performance

Key behaviors and gotchas

  • Returns false if record doesn't exist, table doesn't exist, or ACLs deny read access
  • Respects domain separation — will only find records in accessible domains
  • Always positions the cursor at the found record — no need to call next() afterward
  • Uses the primary key index for optimal performance — faster than any other query type
  • Fails silently on malformed sys_id values — doesn't validate 32-character hex format
  • Table inheritance works normally — child table sys_id values are findable from parent table queries
⚠️

Always check the return value of get() before accessing field values. The GlideRecord object exists even when get() returns false, but all field values will be empty strings.

Free Newsletter

Enjoying this? Get one deep-dive per week.

Join 1,000+ ServiceNow pros — scripts, GlideRecord patterns, Flow Designer techniques, and career moves. Free.

No spam · Unsubscribe anytime