What It Does
The isValid() method checks whether the GlideRecord object was successfully instantiated against a table that exists in the ServiceNow database schema. When you create a new GlideRecord with new GlideRecord('table_name'), the platform validates that the table exists and that you have at least read access to it.
Internally, ServiceNow performs a table metadata lookup during GlideRecord instantiation. The platform checks the sys_db_object table to verify the table exists, then validates your user role has the necessary table-level ACL permissions. If either check fails, the GlideRecord object enters an invalid state.
The method returns true for valid table instantiation and false when the table doesn't exist, has a typo in the name, or when you lack sufficient read permissions. It never returns null or undefined.
Edge cases include dynamic table names constructed at runtime, tables in different application scopes that aren't accessible, and tables that exist but are marked as inactive. The method also returns false for system tables that require elevated privileges, even if the table name is spelled correctly.
This method is unrelated to hasNext(), isValidRecord(), or whether any records exist in the table. A GlideRecord can be perfectly valid according to isValid() while containing zero records or pointing to an empty result set.
When to Use This
Use isValid() when working with dynamic table names, user-supplied input, or when building generic utilities that operate across multiple tables. This is essential in Script Includes that accept table names as parameters, or in Business Rules that might run against tables created by other applications or update sets.
Skip this method when working with known, hardcoded table names like incident or sys_user in standard ServiceNow implementations. Use hasNext() or isValidRecord() instead when you need to check whether records were found or whether the current record contains data.
Common mistake: using isValid() to check if a query returned results. This method only validates the table exists, not whether any records were found.
Return Value
Returns a JavaScript boolean value—either true for successful table instantiation or false for invalid tables. The return value is set during GlideRecord construction and doesn't change based on subsequent queries or operations performed on the object.
The boolean return makes it safe for direct use in if statements without additional null checks. When false, attempting to perform database operations like query() or insert() on the GlideRecord will fail silently or throw exceptions depending on the operation.
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 Business Rules, Script Engines, or notifications fire when calling this method—it's purely a metadata check
- Nothing is written to the database; this is a read-only validation against table metadata
- Extremely fast performance—table metadata is cached at the application server level
- Table-level ACLs are evaluated during instantiation, but record-level security is not checked
- Identical behavior across all server-side contexts—Business Rules, Script Includes, and Scheduled Jobs
- Result is determined at instantiation time and cannot change during the GlideRecord object's lifecycle
- Does not count against any query limits or database connection pools