Aircraft by Modelmodel-aircrafts.com

GlideRecord vs GlideSecure in ServiceNow

You are writing a script that needs to handle user data. If you are reading or changing records, you need GlideRecord. If you are checking permissions or masking sensitive fields, you need GlideSecure.

GlideRecord Handles Data Access and Manipulation

GlideRecord is the standard tool for interacting with database tables. It allows you to query, insert, update, and delete records. You use it when your script needs to work with the actual content of a table, such as finding a specific incident or creating a new user record.

When you instantiate a GlideRecord object, you specify the table name. You then set conditions using methods like equalsQuery or addActiveQuery. After setting your filters, you call query() to retrieve the matching rows. You can loop through the results using next() to access field values.

This class provides direct access to field values. However, this direct access bypasses some security checks. If you use GlideRecord in a background script or a server-side script without proper context, it might return data that should be hidden from the current user. This is why understanding its limitations is critical for secure development.

Common Use Cases for GlideRecord

  • Retrieving a list of open incidents for reporting.
  • Creating a new change request based on user input.
  • Updating the status of multiple records in a batch job.
  • Reading field values to perform business logic calculations.

GlideSecure Enforces Security and Field Masking

GlideSecure is designed specifically for security operations. It does not retrieve data itself. Instead, it works alongside GlideRecord to ensure that sensitive information is handled correctly. Its primary role is to check if a user has permission to view or edit a field and to mask that field if they do not.

Field masking is a key feature. When a field contains sensitive data, such as a social security number or a salary, ServiceNow can hide the actual value from users who lack the necessary privileges. GlideSecure manages these masks. It ensures that even if a script retrieves a record, the sensitive parts remain obscured in the output.

You typically use GlideSecure when building APIs or custom applications that expose data to external systems or less privileged users. It prevents accidental data leaks by enforcing the platform’s security model at the field level. This is essential for compliance with regulations like GDPR or HIPAA.

Key Functions of GlideSecure

  • Checking read access rights for specific fields.
  • Masking sensitive data in query results.
  • Validating write access before allowing updates.
  • Ensuring audit trails capture only authorized changes.

Comparison of Core Capabilities

Understanding the difference between these two classes helps you choose the right tool for the job. GlideRecord is about data movement. GlideSecure is about data protection. Using them together creates a robust and secure solution.

Attribute GlideRecord GlideSecure
Primary Purpose Data retrieval and manipulation Security enforcement and masking
Access Level Direct field access Permission-based access control
Sensitive Data Returns raw values Hides masked fields automatically
Typical Usage Scripts, workflows, UI actions APIs, integrations, secure views
Dependency Standalone Often used with GlideRecord

How to Combine Them for Secure Scripts

The best practice is to use GlideRecord to fetch the data and let GlideSecure handle the security aspects. In many cases, ServiceNow applies security checks automatically when you use GlideRecord in a client-accessible context. However, in background scripts or server-side integrations, you must be more deliberate.

When writing a script, start by initializing the GlideRecord object. Set your queries to find the relevant records. Before accessing any field values, consider whether those fields are sensitive. If they are, rely on the platform’s built-in masking features rather than trying to implement your own security logic.

If you are building an integration that sends data to another system, use GlideSecure to verify what data can be shared. This prevents you from accidentally exposing confidential information. Always test your scripts with different user roles to ensure that the security masks are working as expected.

Step-by-Step Integration Pattern

  1. Initialize GlideRecord with the target table.
  2. Add your query filters to narrow down the results.
  3. Execute the query to load the records.
  4. Loop through the results using next().
  5. Access field values, noting that masked fields will return null or asterisks.
  6. Use GlideSecure methods to explicitly check permissions if needed.

When to Choose One Over the Other

Choose GlideRecord when your goal is to change data or read non-sensitive information. It is the workhorse of ServiceNow scripting. You will use it in ninety percent of your development tasks. It is simple, well-documented, and efficient for general data operations.

Choose GlideSecure when you are dealing with sensitive data or building public-facing interfaces. If you are unsure whether a field is sensitive, assume it is. It is better to err on the side of caution. GlideSecure adds a layer of safety that protects your organization from data breaches.

Do not try to replace GlideSecure with custom code. The platform’s security model is complex and constantly updated. Writing your own access checks is error-prone and difficult to maintain. Let the platform handle the heavy lifting of security enforcement.

Common Pitfalls to Avoid

One common mistake is assuming that GlideRecord respects all security rules in every context. In background scripts, security checks may be bypassed unless you explicitly enable them. This can lead to scripts returning data that should be hidden. Always review your script’s execution context.

Another pitfall is ignoring field masking. If you print out a record containing sensitive fields, you might expose confidential data in logs or console outputs. Ensure that your logging mechanisms respect the same security rules as the rest of the application.

Finally, do not mix up the two classes. GlideSecure does not retrieve data. If you try to use it to find records, your script will fail. Use GlideRecord for retrieval and GlideSecure for validation. Keeping their roles distinct makes your code cleaner and easier to debug.

Related

Published 1 December 2026. Found an error? Tell us.