What It Does
The isNewRecord() method checks the internal state of a GlideRecord to determine if it represents a record that exists in the database. When you create a new GlideRecord using newRecord() or instantiate one without calling get() or query(), the record is considered "new" until it's saved with insert() or update().
Internally, ServiceNow maintains a flag on each GlideRecord instance that tracks whether the record has been persisted. This flag is set when the record is first saved and remains false for the lifetime of the GlideRecord object if it was created programmatically. The method simply returns the boolean state of this internal flag.
The method returns true for genuinely new records and false for existing records loaded from the database. It never returns null or undefined — it's always a proper boolean value. Even empty or invalid GlideRecord objects will return either true or false.
Edge cases include scenarios where a get() call fails to find a record — the GlideRecord remains in a "new" state and isNewRecord() returns true. Similarly, after a failed insert() operation due to ACL restrictions or validation errors, the record remains "new" until successfully saved.
This method complements isValidRecord() and isValid() in the GlideRecord state checking arsenal. While those methods verify if a record exists and is accessible, isNewRecord() specifically tells you about the persistence state — crucial for determining the appropriate business logic path.
When to Use This
Use isNewRecord() primarily in Business Rules that fire on both insert and update operations when you need different behavior for each scenario. Common patterns include setting default values only on insert, sending different notifications for new vs updated records, or applying specific validation rules that only apply to new records. It's also essential in Before Business Rules when you need to perform operations that should only happen once when a record is first created.
Avoid using isNewRecord() when you're working with records loaded via queries — use isValidRecord() instead to check if a record was found. Don't use it as a substitute for proper null checking when dealing with GlideRecord objects that might not be initialized. The method tells you about persistence state, not about whether the object contains valid data.
In Before Business Rules, isNewRecord() reflects the state before any database operations. After calling insert() or update(), the record's state changes and subsequent calls to isNewRecord() will return false.
Return Value
Returns a boolean value — true if the record is new and hasn't been persisted to the database, false if it represents an existing database record. The method never fails or throws exceptions — it always returns a definitive boolean result that can be safely used in conditional statements without additional null checks.
The return value is immediately usable in if statements, ternary operators, and boolean logic operations. Since it's a proper boolean and not a string or object, you don't need to worry about truthy/falsy conversions or type coercion issues that can occur with other ServiceNow API methods.
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
- No database queries are executed — this is a pure state check that reads from the GlideRecord object's internal flags
- No Business Rules, ACLs, or notifications are triggered by calling this method — it's read-only
- Performance is excellent — this is one of the fastest GlideRecord operations since it only accesses in-memory state
- The result is not cached and reflects the current state — if you call
insert()and thenisNewRecord(), it returns the updated state - Behavior is identical across all server-side contexts — Business Rules, Script Includes, Scheduled Jobs, and Background Scripts
- No audit trail entries are created since this method only reads existing state without modifying anything
- The method works correctly even with records that have failed validation or ACL checks — the persistence state is independent of data validity