Published on January 30, 2025.
Yesterday I posted to LinkedIn an interesting Suite.js use case: An interactive, retro-style NetSuite inventory inquiry app.
The user enters an item number, and the description, quantity available, and unit price is displayed. The app integrates with NetSuite using SuiteAPI, and gets the item information via a simple SuiteQL query.
Here's an example.
Click the image to view a larger version.
Several LinkedIn followers reached out to me and asked what the JavaScript code for that app looks like. I've included it below.
If you're not familiar with Suite.js, it's a JavaScript runtime that's designed specifically for NetSuite integration projects. It's especially helpful when it comes to developing apps that automate batch-like, input/output intensive NetSuite processes.
Suite.js will be available for public beta testing in February.
You can learn more about the project here: https://suitejs.io
writeln; writeln( '----------------------------------------------------------------------------------------------------' ); writeln( 'NetSuite / Suite.js Inventory Inquiry' ); writeln( '----------------------------------------------------------------------------------------------------' ); writeln; var nsCredentials = { accountNumber: '9999999_SB1', consumerKey: '*** your consumer key ***', consumerSecret: '*** your consumer secret ***', tokenID: '*** your token id ***', tokenSecret: '*** your token secret ***' } var nsRESTletURL = 'https://9999999-sb1.restlets.api.netsuite.com/app/site/hosting/restlet.nl?script=99999&deploy=1' var query = <<<TEXTBLOCK SELECT Item.ID AS Item, Item.ItemID, Item.DisplayName, ( SELECT SUM( QuantityAvailable ) FROM AggregateItemLocation WHERE ( AggregateItemLocation.Item = Item.ID ) ) AS TotalQuantityAvailable, InvtItemPriceHistory.Price FROM Item LEFT OUTER JOIN InvtItemPriceHistory ON ( InvtItemPriceHistory.Item = Item.ID ) AND ( InvtItemPriceHistory.PriceType = 8 ) AND ( InvtItemPriceHistory.Version = -1 ) WHERE ( Item.ItemID = ? ) TEXTBLOCK>>> var curlProperties = {} curlProperties.OptionCustomRequest = "POST"; curlProperties.OptionURL = nsRESTletURL; curlProperties.OptionHeaders = { "Content-Type": "application/json" }; curlProperties.NetsuiteCredentials = nsCredentials; while ( true ) { writeln( 'Part Number:' ); var partNumber = prompt(); writeln; if ( partNumber == 'quit' ) { abort; } var curlPayload = { procedure: "queryRun", query: query, params: [ partNumber ] } curlProperties.OptionPostFields = JSON.stringify( curlPayload ); curlExecute( curlProperties ); var outputJSON = JSON.parse( curl.output ); var item = outputJSON.records[0]; if ( item === undefined ) { writeln( partNumber + ' was not found.' ); writeln; } else { writeln( 'Description: ' ); writeln( item.displayname ); writeln; writeln( 'Qty Available: '); writeln( '' + item.totalquantityavailable ); writeln; writeln( 'Unit Price: ' ); writeln( '$' + item.price ); writeln; } writeln( '----------------------------------------------------------------------------------------------------' ); }
Hello, I’m Tim Dietrich. I design and build custom software for businesses running on NetSuite — from mobile apps and Web portals to Web APIs and integrations.
I’ve created several widely used open-source solutions for the NetSuite community, including the SuiteQL Query Tool and SuiteAPI, which help developers and businesses get more out of their systems.
I’m also the founder of SuiteStep, a NetSuite development studio focused on pushing the boundaries of what’s possible on the platform. Through SuiteStep, I deliver custom software and AI-driven solutions that make NetSuite more powerful, accessible, and future-ready.
Copyright © 2025 Tim Dietrich.