How to Fix NetSuite SuiteQL Queries Affected by the 2026.2 Default Sort Change
Need help applying this in your account?
Quick answer
NetSuite 2026.2 changed the default sort order for Transaction table SuiteQL queries from tranDisplayName ascending to tranDate descending. Queries that relied on the previous implicit sort now return records in a different order, which may break any logic that assumes the first result is the oldest transaction or that results are alphabetically ordered by transaction name. The fix is to add an explicit ORDER BY clause to every Transaction table SuiteQL query where result order matters. Review all SuiteQL queries that query the Transaction table without an explicit ORDER BY clause and add the appropriate sort before the 2026.2 upgrade reaches your account. The correct practice for SuiteQL in all releases is to never rely on implicit sort order, since NetSuite does not guarantee stable ordering for queries without an explicit ORDER BY. Adding ORDER BY id ASC is a reliable stable sort for any Transaction table query that does not have a more meaningful sort key.
What Changed in the NetSuite 2026.2 SuiteQL Default Sort?
As of NetSuite 2026.2, SuiteQL queries against the Transaction table that do not include an ORDER BY clause now return results sorted by tranDate instead of tranDisplayName.
| Before 2026.2 | From 2026.2 | |
|---|---|---|
| Default sort field | tranDisplayName (alphabetical) |
tranDate (by transaction date) |
| Queries affected | Only those without ORDER BY |
Only those without ORDER BY |
Queries that already include ORDER BY are not affected. This change also applies to SuiteQL used in Analytics Datasets.
Step 1: Find affected queries in your codebase
Search for SuiteQL queries that query the Transaction table without an ORDER BY clause.
In SuiteScript, look for query.runSuiteQL() calls or N/query module usage. The affected pattern looks like this:
query.runSuiteQL({
query: `
SELECT id, tranDate, tranDisplayName
FROM Transaction
WHERE custbody_custom_field = 'value'
`
// No ORDER BY - this is the problem
});Search your codebase for FROM Transaction and review each result for a missing ORDER BY.
Step 2: Decide if order matters for each query
Not every query without ORDER BY needs to be fixed. Only act on a query if your code depends on result order in any of these ways:
- The script reads the first result and expects it to be the most recent or alphabetically first
- The script processes results in a sequence where position matters
- The integration downstream assumes the data arrives in a particular order
- A report or workbook built on the dataset relies on sort order
If the script aggregates all results, looks up by a specific field value, or processes every row regardless of position, the sort change has no impact.
Step 3: Add an explicit ORDER BY to affected queries
To restore the previous alphabetical sort by display name:
query.runSuiteQL({
query: `
SELECT id, tranDate, tranDisplayName
FROM Transaction
WHERE custbody_custom_field = 'value'
ORDER BY tranDisplayName ASC
`
});To sort by transaction date, newest first:
query.runSuiteQL({
query: `
SELECT id, tranDate, tranDisplayName
FROM Transaction
WHERE custbody_custom_field = 'value'
ORDER BY tranDate DESC
`
});To sort by transaction date, oldest first:
query.runSuiteQL({
query: `
SELECT id, tranDate, tranDisplayName
FROM Transaction
WHERE custbody_custom_field = 'value'
ORDER BY tranDate ASC
`
});Specifying ORDER BY explicitly makes your queries immune to future default sort changes.
Step 4: Check Analytics Datasets
If you use SuiteQL in Analytics Datasets, open any dataset definition that queries the Transaction table. Look for queries without ORDER BY and evaluate whether sort order affects the workbooks or reports built on top of those datasets. Apply the same fix: add an explicit ORDER BY.
Step 5: Test in sandbox
After updating your queries, run your scripts in a sandbox environment to confirm results come back in the expected order. Pay attention to scripts that do conditional logic based on the first result, or that pass results to another system in a specific sequence.
Who Is Affected by This SuiteQL Sort Change?
- SuiteScript developers with scripts that run SuiteQL against the Transaction table
- Integration developers using the REST SuiteQL endpoint (
/services/rest/query/v1/suiteql) to query Transaction records - Analytics users who use SuiteQL in Datasets that query or join the Transaction table
Queries against other tables are not affected by this change.
For background on why this change was made, see NetSuite Changed the Default Sort for SuiteQL Transaction Queries in 2026.2.
Related Resources
How to Migrate NetSuite RESTlet Integrations from NLAuth to Token-Based Authentication
NLAuth stops working in NetSuite 2027.1. Here are the steps to audit your RESTlet integrations and migrate them to Token-Based Authentication before the deadline.
How to Use Sequential Batch Processing in NetSuite REST Web Services
NetSuite 2026.2 adds sequential processing for REST batch operations so you can run multiple API requests in a guaranteed order. Here is when to use it and what it means for dependent operations.
Need help applying this in your account?
We work with post-go-live NetSuite accounts every day. Tell us what you're working on.