top of page
Search

SuiteScript 2.0 N/search Module samples

We have heard it at SuiteWorld 2018 echoing both from SuiteCloud Developers as well as the Product Team: The SuiteScript 2.0 N/search Module is both one of the most complex as well as underdocumented modules in SuiteScript 2.0 framework.


In order to promote the marvelous capabilities and efficiencies of the new standard framework, we will dedicate a series of blog posts to the SuiteScript 2.0 and the N/search Module in particular.


What is a search or saved search?

A search is a database query on the NetSuite ERP Oracle Database, defined and executed in Oracle Structured Query Language and as such, allowing for a lot of neat SQL expressions. (There is a neat introduction on the Help Center at https://system.eu1.netsuite.com/app/help/helpcenter.nl?fid=section_n2833020.html, but did you know of distinct() or formatting your results with HTML tags such as <\b> or <\i>?)

There two incredibly powerful things about searches in NetSuite are the Saved Search capabilities:

  1. The Saved Search UI is a single page where Users can create, save, run, publish, schedule, email, or “condition” searches without any SQL.



  1. The database schema of NetSuite is designed for SQL queries. Most telling examples for this are the Transaction and Customer records. The Transaction record contains all transaction types, from Invoices over Supplier Credits to Journal and distinguishes them simply by an attribute field {type}. As a result, you can run a search on the table Transactions and immediately group, summarize, or count financial transactions by GL account, customers, projects, employees – without joining a single table. The Customer record does not just hold actual customers, but also leads, prospects, and projects. This allows to run a saved search across actual financial transactions as well as planned or forecasted transactions or projects associated with customers easily.

How is a search built in SuiteScript?

Shall I load or create saved searches in SuiteScript?


Both SuiteScript frameworks offer to create searches directly in your script (search.create) or load existing saved searches created in the UI (search.load).

We always recommend creating searches in the SuiteScript for the following three reasons:

  1. There is an object less to maintain in your migrations or lists, in this case your sav