I Missed This NetSuite API Detail, and It Cost Me Hours! (Complete problem with solutions)

Hello everyone, I wanted to share a solution to a problem I encountered while working with the NetSuite API, specifically related to downloading sales orders with items using NetSuite API.

I noticed discrepancies in the quantity of some items, particularly affecting assembly-type items, where the quantity and price were not accurately reflected in the SuiteQL query results compared to the REST API.

I-missed-this-NetSuite-API-detail-and-It-cost-me-hours-Inner-Image

Background 

The NetSuite API offers various ways to access data, with SuiteQL and the REST API being two primary methods. Despite their robustness, challenges can arise, as in our case with sales order quantities.

The Problem Identified in the NetSuite SuiteQL query

Our initial SuiteQL query was as follows:


SELECT 
TransactionLine.Quantity,
TransactionLine.Item
FROM 
TransactionLine
JOIN 
Item ON Item.id = TransactionLine.Item
WHERE 
TransactionLine.Transaction = '11453'
AND TransactionLine.AccountingLineType = 'INCOME'
ORDER BY 
TransactionLine.Transaction;

The results, however, were incorrect!

The sales order with ID 11453 had only 1 quantity, whereas the query result was showing -2000. This discrepancy led us to a deeper investigation.

The results, however, were incorrect, leading us to a deeper investigation.

The sales order with id 11453 had only 1 quantity, whereas the query result was showing -2000

Investigation and Analysis of API in SuiteQL

Upon further analysis, I discovered that the discrepancies primarily affected assembly-type items. The quantity and price data retrieved through SuiteQL were not accurate. I encountered an error stating that the Units of Measure table did not exist when attempting to access it for accurate data.

So, I queried for the Units of Measurement table:

select * from unitsTypeUom

The SuiteQL Query Tool interface seamlessly integrates with the NetSuite API, featuring a query editor and options for enabling pagination, formatting results, and displaying null values.

Which returned to me all the existing units of measurement data as shown in the screenshot below.

The spreadsheet interface, integrated with the NetSuite API, displays a list of measurement units and their attributes, such as plural names, abbreviations, and conversion rates. The header indicates that 49 rows were retrieved in just 473 milliseconds.

but when I run the same query in Postman then it give me the following error.

“invalid search query. Detailed unprocessed description follows. Search error occurred: record ‘UnitsTypeUom’ was not found”

Screenshot of a POST request setup in Postman, showing an error response in JSON format for a database query involving the NetSuite API. The environment variable is not defined.

the simple query that works in NetSuite UI but it doesn’t work in [Postman via suiteQL API](https://www.postman.com/jackwen2022/workspace/netsuite/documentation/10085988-be27dfba-3055-4478-9cf4-16b405d1666c).

Solution: NetSuite API User Permission

After several hours of troubleshooting, I found that the NetSuite’s API user needed the correct permission to access the UoM(Units of Measure) table. so after configuring permissions as below my NetSuite API query for UoM started giving results in Postman too !!

The Oracle NetSuite permissions setup page displays various user roles and access levels, seamlessly integrating with the NetSuite API. "Units" is highlighted in the dropdown menu for customization. Save and Cancel buttons are conveniently located at the bottom.

First small success !!

Corrected SuiteQL Query

I rewrote my original query to include UoM calculations, as shown below.


SELECT 
(TransactionLine.Quantity / U.ConversionRate * -1) AS Quantity,
TransactionLine.Item
FROM 
TransactionLine
JOIN 
Item ON Item.id = TransactionLine.Item
JOIN 
UnitsTypeUom U ON U.InternalId = TransactionLine.Units
WHERE 
TransactionLine.Transaction = '11453'
AND TransactionLine.AccountingLineType = 'INCOME'
ORDER BY 
TransactionLine.Transaction;

When I ran the same query in the Postman SuiteQL endpoint, it worked !!

Second success !!

Screenshot of a POST request interface using the NetSuite API, displaying JSON data. Items are listed with "item": "14545" and "quantity": "1" highlighted. Multiple headers and preview tabs are visible, offering a comprehensive view of the interaction details.

Lessons Learned

Resolving this issue in NetSuite took about 6-8 hours, but it could have been accomplished in just 10 minutes with the right configuration in Oracle NetSuite. This experience highlights the importance of understanding the detailed configuration within NetSuite.

Also Read: 2 NetSuite API Integration Strategies You Wish You Knew Sooner

Conclusion

I hope this article proves helpful to anyone working with the NetSuite API and facing it, especially when dealing with similar challenges.

Don’t hesitate to contact us for expert support.
Article by

Jignasha Rathod

Jignasha Rathod is a Technical Analyst with over a decade of experience in the IT industry. She excels in .NET, CI/CD, GitHub, Azure. and has a proven track record in project management, leadership, API integrations, and Azure AI and ML.net . Jignasha is focused on performance enhancement and possesses deep domain expertise in open source CMS ( umbraco, orchard cms ) accounting, CRM, ERP (SAP, NetSuite, Business Central) and e-commerce. Her extensive experience spans across both B2B and B2C e-commerce platforms, and she is leveraging AI and ML technologies to drive innovation and efficiency in client projects.