Skip to content

Developer track

Debugging & performance

Find the problem before it finds production.

2 sections · 13 entries

Debug tools

Built-in tools most developers forget exist. Find them in the All menu.

  • ✦Session Debug. System Diagnostics → Session Debug: switch on Debug Business Rule, Debug Security or Debug SQL for your session only.
  • ✦Script Debugger. Set breakpoints in server-side scripts and step through them live.Hidden gem
  • ✦Script Tracer. Records every server script a form action ran, in order, with field changes.Hidden gem
  • ✦JS Log. Client-side log window for jslog() output.
  • ✦Field Watcher. Right-click a field → Watch to see every script that touched it.Hidden gem
  • ✦ACL debugging. Debug Security shows which ACL allowed or blocked each field and row.
  • ✦Background script dry run. Wrap writes in an if (false) block first and log what would change.

Performance quick wins

Cheap changes with outsized impact.

  • ✦setLimit(). Limit any query where you only need a few rows.
  • ✦GlideAggregate. Count with GlideAggregate, never getRowCount() on a big table.
  • ✦No query in loops. Never run a GlideRecord query inside another query’s while loop; collect IDs and use IN.
  • ✦Indexes. Filter on indexed fields; check Slow Queries for patterns that need one.
  • ✦Client calls. No synchronous GlideAjax (getXMLWait) and no getReference() without a callback.
  • ✦Display BRs. Use g_scratchpad to send data with the form instead of extra calls after load.

Snippets are provided as-is under the MIT licence, without warranty. Test in a sub-production instance first. ServiceNow is a trademark of ServiceNow, Inc.; this page is independent and not affiliated with or endorsed by ServiceNow.