Error Reference

Notification script error: notification script threw exception

Notification script error: notification script threw exception

Where this appears

This error appears in the System Log under System Diagnostics > Log > Application Log when a notification fails to generate due to a JavaScript exception. The error occurs during notification processing when either the message script or condition script encounters a runtime error, preventing the notification from being created or sent.

Sourdough
Chrome Extension

Debugging this in a real instance?

Sourdough lets you trace "Notification script error: notification script threw exception" through system logs, script errors, and API health in the ServiceNow tab you are already using.

Add to Chrome

Free to install. Pro $5/month after a 14-day no-card trial.
Pro requires the ServiceNow admin role. Upgrade inside the extension.

Overview
Tasks
CMDB
API
Metrics
Monitor
Internals
Instance:sourdoughdev·Version:Yokohama
Instance StateONLINE
System StatusFully Operational
Session Timeout90 minutes
Logged-In Sessions2 (20 active)
Build Nameyokohama-12-18-2024_p1
IP Address10.159.128.43
Instance HealthHealth Score: 90%
🔥 5dSourdough (Chrome Plugin)Dark Mode

Cause

JavaScript syntax errors or runtime exceptions in the notification's message script, such as undefined variables, null pointer exceptions, or incorrect method calls. (high likelihood)

Errors in the notification's condition script that prevent proper evaluation, including accessing non-existent fields or methods on the current record. (high likelihood)

Missing or invalid references to GlideRecord objects, system properties, or other ServiceNow APIs within the notification scripts. (medium likelihood)

Script timeout issues when notification scripts contain complex logic or database queries that exceed execution limits. (medium likelihood)

Permission issues where the notification script attempts to access tables or fields that the system user cannot read during notification processing. (low likelihood)

Fix

Step 1: Navigate to System Diagnostics > Log > Application Log and search for the specific notification script error to identify the exact JavaScript exception and line number.

Step 2: Go to System Notification > Email > Notifications and locate the failing notification by searching for notifications related to the table or event mentioned in the error log.

Step 3: Open the notification record and examine both the Message HTML script and Condition script fields for JavaScript syntax errors, undefined variables, or incorrect API usage.

Step 4: Use the Script Debugger or add gs.log statements to the notification scripts to trace variable values and identify where the exception occurs during execution.

Step 5: Test the notification scripts in a Background Script or Script Include to isolate and fix JavaScript errors before deploying back to the notification.

Step 6: Verify that all referenced fields exist on the target table and that proper null checking is implemented for optional fields or related records.

Step 7: Review the notification's When to send conditions and ensure the triggering record context provides all necessary data for the script execution.

Step 8: Test the notification by manually triggering it or creating a test record that meets the notification conditions to confirm the script error is resolved.

Test Your Knowledge

Quick 3-question quiz. See how your ServiceNow skills stack up.

Question 1 of 3Performance

A list view on a table with millions of records is slow. Best fix?

Select an answer to continue