What It Does
The get() method performs a direct record lookup using the primary key (sys_id). When you call this method, ServiceNow bypasses the query engine and goes straight to the database with a SELECT statement targeting the specific record. This makes it significantly faster than constructing a query with addQuery() and query() for single-record retrieval.
Internally, the method validates the sys_id format, executes the database lookup, and populates the GlideRecord object with field values if the record exists. The GlideRecord becomes positioned on the found record, meaning all field accessors (getValue(), getDisplayValue(), dot-notation) immediately work without needing to call next().
The method returns true when a record with the specified sys_id exists and is accessible under current ACL restrictions. It returns false when no record exists, when ACLs deny access, or when the sys_id is empty. The GlideRecord object remains valid but empty when false is returned.
Edge cases include malformed sys_ids (returns false), sys_ids from different tables (returns false), and records that exist but are filtered out by read ACLs (also returns false). You cannot distinguish between these scenarios from the return value alone.
Unlike query() which returns a result set, get() positions the GlideRecord directly on the target record. This means calling next() after a successful get() will return false and move past the record.
When to Use This
Use get() when you have a sys_id and need to retrieve exactly one record. This includes scenarios like following reference field values, processing records from arrays or lists of sys_ids, and lookup operations in Business Rules where you have the current record's sys_id. The method is particularly effective for checking record existence or retrieving parent records via reference fields.
Avoid get() when you need to query by other fields—use addQuery() and query() instead. Never use get() in loops where you're checking existence for many records—batch the lookups with addQuery('sys_id', 'IN', arrayOfIds) for better performance.
Common misuse includes attempting to use get() with field values other than sys_id, calling it repeatedly in loops without caching results, or using it when you actually need multiple records. These patterns indicate you should restructure your approach around proper queries or GlideAggregate for counting operations.
Return Value
Returns a boolean value: true when the record exists and is accessible, false otherwise. The return value is a genuine JavaScript boolean, not a string or number, making it safe to use directly in conditional statements. When true, the GlideRecord object contains all field data and is immediately usable.
When the method returns false, accessing field values will return empty strings or default values rather than throwing errors. Always check the return value before proceeding with field operations to avoid logic errors based on empty data. The GlideRecord remains in a valid state even after failed get() calls and can be reused for subsequent operations.
Enjoying this? Get one deep-dive per week.
Join 1,000+ ServiceNow pros — scripts, GlideRecord patterns, Flow Designer techniques, and career moves. Free.
Platform Behavior & Side Effects
- Read ACLs are enforced—records blocked by ACLs return
falseas if they don't exist - Business Rules do not execute during
get()operations since no data modification occurs - Database performance is optimal—single SELECT by primary key with automatic indexing
- No database writes occur, so audit fields (sys_updated_on, etc.) remain unchanged
- Query caching does not apply since this bypasses the query engine entirely
- Works identically across all server-side contexts (Business Rules, Script Includes, Scheduled Jobs)
- Memory usage is minimal since only one record's data is loaded into the GlideRecord object