Aircraft by Modelmodel-aircrafts.com

Glide Record and Glide Record Secure in ServiceNow

GlideRecord is the standard class for database queries, while GlideRecordSecure restricts access to only what the current user is allowed to see. Using GlideRecord when you need security can expose data that should be hidden, and using GlideRecordSecure when you need performance on a trusted internal script can waste resources checking permissions you already know are granted.

How Do They Differ?

The main difference lies in how they handle row-level security. When you use GlideRecord, the system returns every record that matches your query criteria, regardless of whether the user running the script has permission to view them. This makes it fast but potentially dangerous in public-facing scripts or integrations where data leakage is a risk.

GlideRecordSecure wraps the standard GlideRecord functionality with an additional layer of checks. Before returning any record, it verifies that the current user has read access to that specific table and row. If the user lacks permission, the record is filtered out automatically. This ensures compliance with ServiceNow’s role-based access control policies.

You should choose GlideRecordSecure whenever your script might run under a user context that varies, such as in client scripts, UI actions, or web services. Use GlideRecord only when you are certain that all users executing the code have explicit access to the target table, or when you are performing administrative tasks that require full visibility.

When to Use Each

Use GlideRecordSecure for:

  • Client-side scripts (UI Actions, Client Scripts)
  • Web Services and REST API endpoints
  • Background scripts running under mixed user roles
  • Any scenario where data privacy is critical

Use GlideRecord for:

  • System integration scripts with known service accounts
  • Performance-critical operations where you have verified access
  • Administrative maintenance tasks run by admins only
  • Scripts where you manually enforce security logic

What Changes Performance?

GlideRecordSecure adds overhead because it must check permissions for every row returned. In large datasets, this can significantly slow down execution compared to GlideRecord. The speed difference depends on the complexity of your security rules and the number of records involved.

If you need high performance and are confident about access, GlideRecord is faster. However, if you prioritize security over speed, GlideRecordSecure is the safer choice. You can also optimize GlideRecord by limiting the number of fields retrieved and using indexes effectively.

Optimization Tips

To improve performance with GlideRecordSecure:

  • Limit the result set using filters
  • Select only the fields you need
  • Avoid iterating through large tables unnecessarily
  • Use server-side caching where appropriate

For GlideRecord, ensure you are not retrieving unnecessary data and that your queries are indexed properly. Always test performance in a non-production environment before deploying changes.

Common Mistakes to Avoid

A common mistake is assuming GlideRecord is secure because it runs in a controlled environment. It is not. Any user who can execute the script will see all matching records, even if they do not have direct table access.

Another mistake is using GlideRecordSecure when performance is critical and access is already guaranteed. This adds unnecessary overhead without providing additional security benefits.

Security Best Practices

Always default to GlideRecordSecure unless you have a specific reason not to. Review your security rules regularly to ensure they align with your business needs. Document why you chose one class over the other in your code comments for future maintainers.

How to Check Access Manually

If you are unsure whether a user has access to a table, you can test it by running a simple query with both classes. Compare the results to see if any records are missing in the GlideRecordSecure output. This helps identify potential security gaps in your implementation.

You can also review the Access Control Rules (ACL) in the ServiceNow instance to understand which users have permission to view or edit specific tables. This information helps you decide which GlideRecord variant is appropriate for your script.

Integration with Other Classes

GlideRecord and GlideRecordSecure work well with other ServiceNow classes like GlideAggregate for summarizing data or GlideForm for manipulating form data. However, always ensure that security checks are applied at the right level to prevent unauthorized data access.

When combining these classes with business rules or scheduled jobs, remember that the context in which the script runs determines the effective user. A background job running as a system administrator may bypass some security checks, so be cautious when designing automated processes.

Testing Your Implementation

Test your scripts with different user roles to ensure that security is working as expected. Use the ServiceNow debugger to step through your code and verify that the correct records are being returned. This helps catch issues early and prevents data leaks in production.

Regularly audit your scripts to ensure they comply with current security policies. As your organization’s access controls evolve, your scripts may need to be updated to reflect new requirements. Keeping your code secure and performant requires ongoing attention and testing.

Related

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