NetSuite Tips & Tricks: Easy NetSuite Search

We are excited to introduce a guest author today - one of our very own Senior Consultants, Karl-Henry Martinsson!  Keep an eye on The Vested Group's blog for more posts from Karl in the future or simply visit his personal blog directly at


In an attempt to expand my knowledge to other platforms than Notes and Domino, I have now been working with NetSuite for a number of months. I have mainly been working with the ERP part of the cloud based system.

The language used is called SuiteScript, and it is Javascript with a NetSuite-specific API to work directly with the databases. Knowing Javascript makes it easy to get started, just like knowing Visual Basic makes it easy to learn Lotusscript. And just like with Lotusscript, you have to learn the NetSuite specific functions.

Since I like my code clean and easy to read (which will make future maintenance easier), I have created a number of functions to encapsulate NetSuite functionality.

The first one I created was to search the database. The search in NetSuite is done by defining the columns (i.e. fields) to return as an array of search column objects. Then an array of search filters is created, and finally the search function is called, specifying what record type to search and passing the two arrays to it as well. This is a lot of code, and with several searching in a script it can be very repetitive, not to mention hard to read.

Here is an example of a traditional NetSuite search:

KHM 1.jpgUsing my function, the code wold be simplified to this:

KHM 2.jpgThe function also support saved searches. Simply add the following line:

KHM 3.jpgThere is a limitation in SuiteScript so that a maximum of 1000 records can be returned by a normal search. There is a trick to bypass this, but it requires some extra coding. So I thought why not add this into the function as default? So I did.

Below is the code for the search function. I usually put it in a separate file and reference it as a library in the scripts where I want to use it. This first version does not support more advanced functionality like formulas in the filters, but for most searches this function will be usable.

KHM 4 1.jpgKHM 4 2.jpgKHM 4 3.jpg


Comments (0)

Subscribe to The Vested Group Blog Email Updates