Error Reference

GlideRecord query returned no results for expected record

GlideRecord query returned no results for expected record

Where this appears

This error appears in ServiceNow server-side scripts, Business Rules, Script Includes, and client scripts when a GlideRecord query fails to return expected data. The error typically shows in the System Log under System Diagnostics > Log > Application Log or in script debugging output when developers expect at least one record but get zero results.

Sourdough
Chrome Extension

Debugging this in a real instance?

Sourdough lets you trace "GlideRecord query returned no results for expected record" 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

Incorrect table name specified in the GlideRecord constructor, including typos or referencing a non-existent table extension. (high likelihood)

Wrong encoded query syntax or field names that don't match the actual table schema, causing the query to match no records. (high likelihood)

Missing or incorrect Access Control Rules (ACLs) preventing the user context from reading records that actually exist in the table. (medium likelihood)

Query executing against empty table or records were recently deleted, making previously valid queries return no results. (medium likelihood)

Script running in wrong application scope, preventing access to scoped tables or records in different application contexts. (low likelihood)

Fix

Step 1: Verify the table name in your GlideRecord constructor by checking System Definition > Tables and confirming the exact table name spelling and case sensitivity.

Step 2: Test your encoded query in a filter on the actual table through the ServiceNow interface to confirm it returns expected records before using it in code.

Step 3: Add debugging by logging the query details using gs.info() before executing, including table name, encoded query, and getRowCount() to verify record existence.

Step 4: Check Access Control Rules under System Security > Access Control (ACL) to ensure your user context has read access to the target table and fields.

Step 5: Run the query as an admin user temporarily to determine if ACL restrictions are causing the no results condition.

Step 6: Verify your script's application scope matches the table's scope by checking both the script's and table's application assignments.

Step 7: Add proper error handling with hasNext() or next() validation before accessing GlideRecord fields to prevent assuming records exist.

Step 8: Review recent data changes or imports that might have affected the expected records by checking System Logs > Data Sources or recent update sets.

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