Sample NetSuite SuiteScript 2.0 Search Example for Nulls, Joins and Group By

This article is relevant if you are a SuiteScript developer and you want to better understand SuiteScript 2.0 semantics.

Background

During a recent engagement with one our newer technical consultants, he needed some assistance to develop a search to look up an item fulfillment that did not have a reference to a custom file attachment.  He was confused because the NetSuite Saved Search user interface did not offer a way to select a null (none) reference.  As such, I offered some guidance which helped him understand references to empty values in searches.  I surmised that others in the Netsuite community may also wonder the same and offered this article.  This article is very similar to the article I previously posted, NetSuite SuiteScript 2.0 Search Join and Summary Example. The following code snippet may be helpful to fellow NetSuite SuiteScript developers.

Sample SuiteScript 2.0

//sample suitescript 2.0 search expression illustrating file lookup on none and join with
//group by to get a single value

var n = 'mynote;'
var a = new Array();
//search where there is no reference to a file
a[0] = search.createFilter({ name:'custbody_prolecto_export_file_ref', 
	operator:'ANYOF', 
	values:'@NONE@'}
);

//search for a specific instance of a note
a[1] = search.createFilter({ name:'note', 
	join:'usernotes', 
	operator:'IS', 
	values:n}
);
     
//assemble the search and include join operator on output	 
var s = search.create({'type':'itemfulfillment'
	 ,'filters':a 
	 ,'columns':[ search.createColumn({'name':'internalid',
		'summary':search.Summary.GROUP}
	)]}
);

//run search to see results
var result = s.run();

Work with NetSuite Technical Leaders

NetSuite’s platform is rich with possibilities and a wonder to those individuals who understand how to leverage existing structures to solve real-world business challenges.  Our team values actors that can think and lead clients to elegant  solutions.  If you feel you are under appreciated and wish to be with an organization that holds high standards for care an excellence, let’s have a conversation.

Be Sociable, Share!

Marty Zigman

Holding all three official certifications, Marty is regarded as the top NetSuite expert and leads a team of senior professionals at Prolecto Resources, Inc. He is a former Deloitte & Touche CPA and has held CTO roles. For over 30 years, Marty has produced leadership in ERP, CRM and eCommerce business systems. Contact Marty to set up a conversation.

More Posts - Website - Twitter - Facebook - LinkedIn - YouTube

| Category: NetSuite | Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *