What It Does
The gs.isInteractive() method checks the execution context of the current thread to determine if it's running within an interactive user session. ServiceNow maintains context flags throughout the request lifecycle that distinguish between user-initiated actions and system-generated processes. When a user submits a form, clicks an Action Button, or loads a list view, ServiceNow sets internal flags indicating this is an interactive request where the user expects an immediate response.
Internally, ServiceNow tracks the request source through session attributes and thread-local variables. Interactive sessions include form submissions, UI Actions, Client Scripts making server calls, and Direct Web Services calls from the UI. The platform maintains this context even through multiple Business Rule executions, Script Include calls, and database operations that might occur during a single user transaction.
The method returns true for user-driven requests and false for background processes including Scheduled Jobs, Business Rule Engines processing email, REST API calls from external systems, Import Sets, Data Sources, and Transform Scripts. Notification generation, Workflow activities, and Flow executions also return false unless they were triggered by a direct user action.
Edge cases include situations where the context can change mid-execution. If an interactive Business Rule triggers a Script Include that makes a REST call to another ServiceNow instance, the gs.isInteractive() call in the original Business Rule returns true, but any server-side scripts executing on the remote instance would see false. The method also returns false during system startup, system clone operations, and when running through the ServiceNow CLI or developer tools.
This method is related to gs.isLoggedIn() but serves a different purpose. While gs.isLoggedIn() checks if there's an authenticated user session, gs.isInteractive() specifically identifies whether that user is actively waiting for a response. A scheduled job running as a specific user would have gs.isLoggedIn() return true but gs.isInteractive() would return false.
When to Use This
Use gs.isInteractive() when you need different behavior based on whether a user is actively waiting for the operation to complete. This is particularly valuable in Business Rules where you want to perform expensive operations (like complex calculations or external system calls) only during background processing, while keeping user-facing transactions fast and responsive. Common use cases include conditional logging (verbose logging for background jobs, minimal logging for interactive requests), different validation rules (strict validation for user input, automated cleanup for batch operations), and performance optimizations.
Avoid using this method when you really need to check authentication status (use gs.isLoggedIn() instead) or user roles (use gs.hasRole()). Don't use it as a substitute for proper ACL implementation or as a way to bypass security controls. The method is also not appropriate for determining whether to show or hide UI elements — Client Scripts and UI Policies handle that better since they run on the actual user interface.
A common misuse pattern is developers who think gs.isInteractive() can distinguish between manual record updates versus automated updates. This fails because REST API calls from legitimate integrations return false, but so do legitimate system processes like Workflow. If you need to track the true source of changes, implement proper audit trails using gs.getSession() and session attributes, or use Business Rule conditions based on gs.getUserName() and specific integration users.
Return Value
The method returns a Boolean value: true for interactive user sessions, false for background or automated processes. The method never returns null or undefined — it always provides a definitive boolean result based on the current execution context. There are no failure conditions for this method since it's simply reading internal platform state.
The return value is safe to use directly in conditional statements without null checking or type conversion. Since JavaScript treats true and false as proper boolean values, you can use it in logical operations, ternary expressions, and compound conditions without additional safeguards.
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 operations are performed — this method reads from in-memory session context only
- Execution is extremely fast with no caching needed since it accesses thread-local variables
- The same value persists throughout the entire request lifecycle, including all Business Rule phases (before, after, async)
- Script Includes called from Business Rules inherit the same interactive state as the triggering Business Rule
- No audit entries, workflow triggers, or notifications are generated by calling this method
- ACL evaluation is not triggered since this method only reads system context, not user data
- The result remains consistent even when Business Rules create or update other records during the same transaction