Why SuiteQL says “Record ‘transaction’ was not found”

On this page

The transaction table is there. Your role can’t see it. SuiteQL reports a table the role has no access to as “Record ‘x’ was not found”, and for transaction the permission to add is Find Transaction, on the Transactions subtab of the role. Add it at View, keep a permission for each transaction type you want rows from, and the same query runs.

I hit this with a token role I use for read-only scripted queries, set up the way I describe in how to give Claude Code read-only access to NetSuite. The role had Sales Order. It could open a sales order by ID over the REST record API, and SuiteQL still insisted the table didn’t exist.

transaction is only the commonest case, though. Customers, employees and custom records fail the same way, and one case doesn’t fail at all. So this post is the method as well as the fix.

Two errors that look alike

SuiteQL has two answers for a table it won’t query, and they mean different things. Both came from a sandbox, through the script from that earlier post:

Bash
NS_ENV=sandbox node tools/netsuite/ns.js suiteql "SELECT COUNT(*) AS n FROM transactionz"
# SuiteQL failed: HTTP 400
# Invalid search query. Detailed unprocessed description follows. Invalid search type: transactionz.

NS_ENV=sandbox node tools/netsuite/ns.js suiteql "SELECT COUNT(*) AS n FROM customer"
# SuiteQL failed: HTTP 400
# Invalid search query. Detailed unprocessed description follows. Search error occurred: Record 'customer' was not found.

The text after “HTTP 400” is NetSuite’s own error detail. Read the end of it:

What you queriedWhat comes backWhat it means
A name that doesn’t exist, like transactions or a custom record this account doesn’t haveInvalid search type: transactions.Check the spelling, and whether the record type exists in this account
A table that exists, which the role can’t readSearch error occurred: Record 'customer' was not found.A permission is missing
A table the role can read, holding rows of a type it can’tRows, minus the hidden ones. No errorA permission is missing, and nothing tells you

“Not found” is what sends people hunting for typos, and a typo gives the other message. Capitals don’t cause it either: FROM Transaction returned the same count as FROM transaction.

The table in the error isn’t always the one after FROM. A join fails the whole query. transaction joined to customer came back as Record 'customer' was not found on a role that could read transaction by itself. Fix the table the error names and run the query again, because a second join can fail once the first one is through.

What SuiteQL checks

SuiteQL enforces the same role-based access restrictions as SuiteAnalytics Workbook. Workbook’s access to record types and fields depends on the same permissions used for NetSuite saved searches. So the question for any table is whether this role could run a saved search on that record type.

Over REST, check the role’s base permissions before any of that. Oracle lists three that every REST web services role needs: REST Web Services, Log in using Access Tokens and SuiteAnalytics Workbook.

The transaction table needs Find Transaction

Find Transaction is the permission behind transaction searches. Oracle’s permissions for searches page says View lets you run transaction searches but not save them, and Create or higher adds the Create Saved Search button. SuiteQL only reads, so View is enough.

Add it in Setup > Users/Roles > User Management > Manage Roles. Edit the role, open the Permissions subtab, then Transactions, pick Find Transaction and set it to View.

I tested it on a sandbox role with the Sales Order, Invoice, Item Fulfillment, Fulfill Orders, Bills and Pay Bills permissions, all at View or higher. With Find Transaction taken off, SELECT COUNT(*) FROM transaction failed with Record 'transaction' was not found, and transactionline failed the same way. A sales order still opened by ID over the REST record API, and FROM salesorder still read. With Find Transaction back at View, both tables read again. Nothing else on the role changed.

Oracle’s documentation doesn’t say this outright for SuiteQL. Its API permissions page says that for SuiteScript and SOAP you “may need the Find Transaction permission to retrieve a record using the GET operation.” In my test the GET by ID worked without it and the query didn’t.

Then one permission per transaction type

Find Transaction opens the table. What’s in it is decided by the type permissions. Oracle’s example: “to access sales order data through the transaction record type using Workbook, you must have the Sales Order permission assigned to your role.”

A missing type permission doesn’t raise an error. The rows of that type just aren’t there, and that’s the case that costs time, because the query looks fine. This is the role from the test above, on an account that has plenty of purchase orders and customer payments. I checked both lists in the UI:

Bash
NS_ENV=sandbox node tools/netsuite/ns.js suiteql "SELECT DISTINCT type FROM transaction ORDER BY type"
JSON
[
  { "type": "CustInvc" },
  { "type": "ItemShip" },
  { "type": "SalesOrd" },
  { "type": "VendBill" },
  { "type": "VendPymt" }
]

No purchase orders and no customer payments, because the role has no permission for either. WHERE type = 'PurchOrd' returned a count of 0, with no error and no warning.

The table for a single type behaves differently. salesorder and invoice read with Find Transaction on and off, and each returned the same count as transaction filtered to that type. purchaseorder failed with Record 'purchaseorder' was not found both times. As far as I can tell, each of those tables checks only its own type permission. So FROM purchaseorder tells you a permission is missing, and FROM transaction WHERE type = 'PurchOrd' tells you nothing.

So a query that sums invoices is right, and one that sums every transaction quietly isn’t. Before you trust a total from a token role, run that DISTINCT type query and check the list against what the account holds. If a type is missing, add its permission at View.

transactionline needed nothing extra on this role. It read as soon as transaction did.

Ask the record API which permission is missing

SuiteQL won’t name the permission. The REST record API will. Ask it for one record of the type, by any ID, even one that doesn’t exist, and the 403 says what the role lacks. Permission is checked before the ID:

Bash
NS_ENV=sandbox node tools/netsuite/ns.js get customer 1
# GET customer/1 failed: HTTP 403
# Permission violation: Permission Violation: You need  the 'Lists -> Customers' permission to access this page. Please contact your account administrator.

The double space is NetSuite’s. The same request for the other tables that failed:

TableWhat the 403 named
customerLists -> Customers
contactLists -> Contacts
employeeLists -> Employee Record
A custom record type“a higher permission for custom record type Job Tracker”

Treat the name as a lead and check it before you add it. Employee Record is the one that misleads. Oracle’s employee permission pages say it gives the “ability to see NetSuite menus related to employees” and that it “doesn’t give access to the employee record”. The permission that does is Lists > Employees, which Oracle says “gives full-record access to employee records”. That’s far more than a read-only role should hold, so think twice before you give a token role employees at all.

transaction itself isn’t a record type to the record API. get transaction 1 returns a 404, Record type 'transaction' does not exist. Ask for a sales order or an invoice instead. That tells you about the type permission, not Find Transaction, which is why the DISTINCT type check above still matters.

Custom records follow their access type

A custom record type decides its own permission model, in the Access Type field on the record type. Oracle describes three options:

Access TypeWho gets access
Require Custom Record Entries Permission, the defaultRoles granted the record type, which can be set on the Lists subtab of the role’s Permissions subtab
Use Permission ListRoles listed on the record type’s own Permissions subtab. It can also be set on the Custom Records subtab of the role
No Permission Required for Internal RolesEvery internal role, to create, read, update and delete, with no grant needed

So one role can read some custom records with no grant and fail on others, and the access type is the first thing to check when it does. I tried thirteen custom record types on the sandbox role. Eight read, two of them because the role had been granted them, and six with no grant at all. Two returned Record '<name>' was not found, and the record API named the record type for each. Three returned Invalid search type, and the record API’s 404 confirmed none of the three exist in that account.

It also explains “it works for me”. Oracle notes that the owner of a custom record type “always has full permission to access the custom record type in any role.” That’s the user, not the role, so switching your own login to the integration’s role proves nothing, and neither does a token issued to you. Test as the integration’s user and role.

A record type that doesn’t exist at all gives a 404 from the record API, not a 403: Record type 'customrecord_doesnotexist' does not exist. That catches the bundle installed in production and not in the sandbox.

In SuiteScript

Oracle’s SuiteQL page covers the N/query module as well as REST, so a script’s queries meet the same checks. query.runSuiteQL has an option for what happens when a permission is missing. Oracle documents metaDataProvider with two values. SUITE_QL, the default, makes the query fail “if you attempt to access fields or records without the necessary permissions.” STATIC lets it succeed, but it “does not return any data for those fields or records.”

I’d leave it on the default. STATIC turns the loud failure into the quiet kind from the transaction types section.

Five script types let a deployment pick the role it runs as. Oracle lists the script types that support Execute as Role: Suitelet, User Event, Portlet, Mass Update and Workflow Action. RESTlets aren’t on the list. Oracle doesn’t spell out what that means for a RESTlet’s queries, but I’d read it as: give the role that calls the RESTlet the permissions its queries need, since there’s no deployment setting to lift them.

After a sandbox refresh

Roles are per account. A permission you add in the sandbox is lost at the next refresh, which copies production’s configuration over the sandbox and overwrites “any changes you have made to the target sandbox account”. Add the permission in production too, or put it on your after-refresh list. A refresh also deletes the sandbox’s access tokens, so a script’s queries stop altogether until you issue a new one.

This post is part of the SuiteScript cluster. The tools I use are on the resources page.

Frequently Asked Questions

Is the table called transaction or transactions?

transaction, singular. FROM transactions returns Invalid search type: transactions. Capitals don't matter.

Why can I open a sales order over the REST record API but not query it with SuiteQL?

They check different permissions. In my test the record API opened a sales order without Find Transaction, and the transaction table needed it. The salesorder table didn't.

Why does my query work in the UI and fail from my integration?

Each runs as a different user and role. Run it as the integration's user and role. If it touches a custom record type you own, Oracle says the owner always has full access in any role, so your own test can pass where the integration fails.

Can I make SuiteQL skip what the role can't read instead of failing?

In SuiteScript, yes. Set metaDataProvider to STATIC on query.runSuiteQL, and fields and records the role can't read come back with no data. The query then succeeds while returning less than you asked for, so it's safer to fix the role.

Does Find Transaction let a role change transactions?

Oracle describes it only in terms of running and saving transaction searches, so I give it at View and keep the type permissions at View too for a read-only role. The rest of the role I use is in how to give Claude Code read-only access to NetSuite.

Working on a NetSuite project? Get in touch.