What It Does

The getID() method extracts the sys_id field from the underlying sys_user record that the GlideUser object represents. This is the 32-character unique identifier that ServiceNow uses internally to reference the user across all tables and relationships.

Internally, ServiceNow maintains a reference to the sys_user record within the GlideUser object. When you call getID(), the platform simply returns the value of the sys_id field from that cached record reference. No database query is executed since the GlideUser object already contains this information.

The method returns a 32-character string in standard ServiceNow sys_id format. It will never return null or undefined when called on a valid GlideUser object, as every user record must have a sys_id. However, if the GlideUser object itself is invalid or represents a user that no longer exists, the behavior depends on how the GlideUser was obtained.

Edge cases include scenarios where the user account has been deleted after the GlideUser object was created, or when working with system users like the 'guest' user. The method will still return the sys_id even if the user is inactive, as it's reading from the object's internal state rather than validating current user status.

This method is functionally equivalent to gs.getUserID() when called on the current user, but getID() can work with any GlideUser object, not just the current session user. Other related methods in the GlideUser class include getName() and getUserName() which return different user identifiers.

When to Use This

Use getID() when you already have a GlideUser object and need its sys_id for record lookups, assignments, or audit trails. This is particularly useful in Script Includes that accept GlideUser parameters, or when iterating through multiple users where you need to maintain user context. The method is also the correct choice when building queries that filter by user sys_id or when setting reference fields that point to sys_user records.

If you only need the current session user's sys_id, use gs.getUserID() instead as it's more direct and doesn't require object instantiation. Avoid using getID() when you need the username string—use getUserName() instead. Also avoid this method if you need the display name, as getName() or getDisplayName() would be more appropriate.

Return Value

Returns a string containing the 32-character sys_id in standard ServiceNow format (8-4-4-4-12 hexadecimal pattern, though typically displayed without hyphens). The string is always exactly 32 characters long and contains only alphanumeric characters. The encoding is UTF-8 compatible ASCII, making it safe for use in URLs, database queries, and cross-system integrations.

The method does not return null, undefined, or empty string under normal circumstances. If called on an invalid GlideUser object, the platform behavior is undefined and may throw a JavaScript error. Always ensure your GlideUser object is valid before calling this method, and treat the returned string as immutable—never attempt to modify sys_id values as they are managed exclusively by the ServiceNow platform.

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 database queries are executed—the method reads from the GlideUser object's internal cache
  • No Business Rules, ACLs, or notifications are triggered as this is a read-only operation
  • Performance is extremely fast (sub-millisecond) as it's a simple property accessor
  • Nothing is written to the database or audit tables when this method executes
  • Behavior is identical across all server-side contexts (Business Rules, Script Includes, Scheduled Jobs)
  • The returned sys_id reflects the user state at the time the GlideUser object was created, not current database state
  • Method calls are not logged in system logs unless custom logging is implemented around the call