What It Does

The tableExists() method queries the sys_db_object table to determine if a specified table exists in the current instance. This is a direct database dictionary lookup that checks whether the table name is registered in ServiceNow's metadata.

Internally, ServiceNow performs a query equivalent to new GlideRecord('sys_db_object').get('name', tableName). The method leverages ServiceNow's table dictionary cache, making it relatively fast for repeated calls within the same transaction.

The method returns true for any table that has a dictionary entry, including base tables, extended tables, and tables from scoped applications. It returns false for non-existent tables, misspelled table names, or tables that have been deleted but may still be referenced in code.

The method respects table-level ACLs and will return false if the current user lacks read access to the table, even if the table physically exists. This security feature prevents information disclosure about restricted tables but can create unexpected behavior in system-level scripts.

Related methods include gs.getProperty() for checking if plugins are active, and GlideTableHierarchy.getAllExtensions() for discovering table inheritance relationships. Unlike those methods, tableExists() provides a simple boolean answer about table existence.

When to Use This

Use tableExists() when building dynamic queries or reports that might reference tables from optional plugins like ITOM, SecOps, or HRSD. Script Includes that work across multiple instances should check table existence before attempting operations. This prevents runtime errors when code runs on instances without required plugins activated.

Avoid using this method for standard platform tables like incident, sys_user, or task that exist in all ServiceNow instances. For plugin detection, use gs.getProperty('glide.plugin_name.active') instead of checking individual plugin tables. Common misuse includes checking table existence in tight loops where caching the result would be more efficient.

Never use this method as a substitute for proper error handling around GlideRecord operations. A table might exist but be inaccessible due to ACLs, or become unavailable between the check and the actual query. Always combine existence checks with try-catch blocks for robust error handling.

Return Value

Returns a JavaScript boolean value: true if the table exists and is accessible to the current user, false otherwise. The method never returns null or undefined, making it safe to use directly in conditional statements without additional null checks.

The return value is immediately usable in boolean contexts. When the method returns false, it could indicate either a non-existent table or an access control restriction. The method provides no mechanism to distinguish between these scenarios, so additional logging or error handling may be necessary for debugging purposes.

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

Platform Behavior & Side Effects

  • No Business Rules, ACLs, or notifications fire during the table existence check
  • Nothing is written to the database; this is a read-only metadata operation
  • Performance is generally fast due to dictionary caching, but first calls may be slower
  • Respects table-level ACLs, potentially returning false for tables that exist but are restricted
  • Works identically in Business Rules, Script Includes, and Scheduled Jobs
  • Does not trigger any audit logging or session tracking
  • Results may be cached within the same transaction but not across different requests