‹ All interview questions

Core Concepts

In .NET, you've handled exceptions with try-catch, global exception handlers, and Application Insights for…

The question

In .NET, you've handled exceptions with try-catch, global exception handlers, and Application Insights for monitoring. How does error handling and debugging work in ServiceNow? Walk through the tools you'd use to diagnose a failing Business Rule in production.

Why This Comes Up in Interviews

ServiceNow's debugging toolkit is different from Visual Studio's debugger or Application Insights — there are no breakpoints, no step-through debugging, and no local development environment. Everything runs on the remote instance. This question tests whether you can be effective with platform-native tools.

The Debugging Toolkit Map

// .NET Debugging (what you know)
// Visual Studio Debugger    → No equivalent (no breakpoints)
// Console.WriteLine()       → gs.info(), gs.warn(), gs.error()
// Application Insights      → System Logs + Transaction Logs
// Exception stack trace     → Script Tracer output
// Postman for API testing   → REST API Explorer (built-in)
//
// ServiceNow-Specific Tools:
// Script Debugger           → Step-through for Business Rules
// Session Debug             → Enable detailed logging per session
// Transaction Log           → Performance + error correlation
// Background Script         → Quick script testing (like LINQPad)

Diagnosing a Failing Business Rule

  • Step 1 — Check System Logs: Navigate to System Logs → All. Filter by 'source' = the Business Rule name or by timestamp. Look for gs.error() output and JavaScript exceptions. Like checking Application Insights for your exception telemetry.
  • Step 2 — Enable Session Debug: Go to the session debug modules: 'Debug Business Rule', 'Debug Security Rules'. This logs every BR execution, including timing and input/output — like setting the log level to DEBUG for a specific request in .NET.
  • Step 3 — Script Tracer: This is the closest thing to a debugger. It records every server-side script execution with timing, showing the call stack. Like a poor man's Application Insights request trace.
  • Step 4 — Background Script: Reproduce the issue in isolation by running the Business Rule logic directly in a Background Script. Like using LINQPad to test a C# method outside of your application.
// Structured error handling in a Business Rule
(function executeRule(current, previous) {
  try {
    var helper = new IncidentHelper();
    var result = helper.processEscalation(current);
    
    if (!result.success) {
      gs.error('Escalation failed for ' + current.number + 
               ': ' + result.message);
      // Don't abort — log and continue gracefully
    }
  } catch (ex) {
    // Catch JavaScript errors — like a global exception handler
    gs.error('BR Exception on ' + current.number + 
             ': ' + ex.message);
    // Optionally create an incident for the error
    var errInc = new GlideRecord('incident');
    errInc.initialize();
    errInc.short_description = 'System Error: Escalation BR';
    errInc.description = ex.message + '\n' + ex.stack;
    errInc.insert();
  }
})(current, previous);

Key Differences from .NET

  • No local dev: You can't F5 and debug locally. All testing happens on the instance. Background Scripts are your REPL.
  • No structured logging framework: No Serilog, no NLog. Use gs.info/warn/error() with structured messages and correlation IDs (like the incident number).
  • Transaction limits: Scripts that exceed execution time limits are killed by the platform — like Azure Functions timing out. Monitor with Transaction Logs.
💡 .NET Developer Pro Tip

The REST API Explorer (System Web Services → REST API Explorer) is your built-in Postman. Use it to test Table API and Scripted REST calls with authentication already handled. Combined with Background Scripts for server-side testing, you have a workable debugging loop — just without the IDE comfort you're used to.