Error Reference

Workflow activity fault: activity script threw an exception

Workflow activity fault: activity script threw an exception

Where this appears

This error appears in the workflow context log when a Run Script activity within a workflow encounters a JavaScript runtime exception. The error is visible in the workflow context under System Workflow > Live Workflows or when viewing the workflow context record directly. It occurs during workflow execution when the JavaScript code in a Run Script activity fails to execute successfully.

Sourdough
Chrome Extension

Debugging this in a real instance?

Sourdough lets you trace "Workflow activity fault: activity script threw an 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 error or runtime exception in the Run Script activity code, such as calling methods on null or undefined objects. (high likelihood)

Attempting to access workflow variables or system properties that don't exist or are null at runtime. (high likelihood)

GlideRecord queries failing due to invalid table names, field names, or insufficient access rights to the referenced tables. (medium likelihood)

Memory or timeout issues when the script runs too long or consumes excessive resources during execution. (medium likelihood)

API calls or integrations within the script failing due to network issues, authentication problems, or external system unavailability. (low likelihood)

Fix

Step 1: Navigate to System Workflow > Live Workflows and locate the faulted workflow instance to identify the specific Run Script activity that failed.

Step 2: Click on the faulted activity in the workflow context to view the detailed error message and stack trace in the activity log.

Step 3: Examine the JavaScript code in the Run Script activity by opening the workflow definition and reviewing the script for syntax errors, null reference issues, or undefined variables.

Step 4: Check the System Log at System Diagnostics > Log > Application Log for additional JavaScript error details that occurred around the same timestamp.

Step 5: Verify that all workflow variables referenced in the script exist and contain expected values by checking the workflow context variable values.

Step 6: Test the problematic JavaScript code in a background script (System Definition > Scripts - Background) to isolate and debug the specific issue.

Step 7: Add proper error handling using try-catch blocks around potentially failing operations and validate objects before calling methods on them.

Step 8: Restart the workflow from the faulted activity after fixing the script by right-clicking the activity and selecting appropriate retry options.

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