Marty Zigman

Conversations with Marty Zigman

Certified Administrator • ERP • SuiteCloud

How To: NetSuite Saved Search with List of Internal IDs

NetSuite Reporting Technical

Tags: , , , ,

This article is relevant if you need to work with a NetSuite Saved Search or Mass Update and you want to provide a list of data, internal ids, or information to drive your query.

Background

When working with NetSuite, sometimes we encounter situations where the information we need to filter with is provided by an external list.  Suppose you have a list of internalids offered in a spreadsheet and now you want to use that list to lookup records.  In a recent case, I needed to write a custom mass update for my client to change the values on a number of Sales Orders.   They had the  record internal ids for the Sales Orders in a spreadsheet. Internalids are very valuable in NetSuite search operation.

NetSuite Saved Search provides the foundation for performing a query on the business platform.  NetSuite’s Saved Search is similar to a SQL SELECT statement.  One of the great things about SQL is that you can perform a query where you provide a list of values as your where clause criteria.  For example, “SELECT * FROM orders WHERE internalid IN (2978, 3105, 3086)” will retrieve the records where the internalid matches on the three values.   But how do you perform the equivalent in NetSuite?

Use a Spreadsheet to Craft a NetSuite Formula

Since NetSuite sits on top of the Oracle database system, you can use PL/SQL (Oracle’s Database Programming Language) to generate specialized queries.  Using some simple spreadsheet formulas, I was able to quickly craft the foundation of a CASE statement.   The CASE statement can be used to act like a SQL IN operator. See image for the basic syntax.

Once I have crafted a portion of the CASE statement, I can cut-and-paste to my notepad editor and add the starting and ending syntax elements.    See below for a sample.

CASE {internalid}

	WHEN 2978 THEN 1
	WHEN 3105 THEN 1
	WHEN 3086 THEN 1
	WHEN 3099 THEN 1
	WHEN 3113 THEN 1
	WHEN 3114 THEN 1
	WHEN 3102 THEN 1
	WHEN 3103 THEN 1
	WHEN 3109 THEN 1
	WHEN 3116 THEN 1
	WHEN 3118 THEN 1
	WHEN 3120 THEN 1
	WHEN 3123 THEN 1
	WHEN 3124 THEN 1
	WHEN 3126 THEN 1
	WHEN 3127 THEN 1
	WHEN 3128 THEN 1
	WHEN 3129 THEN 1
	WHEN 3130 THEN 1
	WHEN 3131 THEN 1
	WHEN 3132 THEN 1
	WHEN 3133 THEN 1
	WHEN 3135 THEN 1
	WHEN 3136 THEN 1
	WHEN 3137 THEN 1
	WHEN 3138 THEN 1
	WHEN 3139 THEN 1
	ELSE 0
END

Once you have the CASE statement, you can feed this string to a Formula (numeric) Filter and check for the value of 1. See screen shot for approach.

Get More out of NetSuite

The key to understanding the power of NetSuite Saved Search is to visualize that the Query tool is crafting a SQL query to the Oracle database.  Hence, if you are comfortable with these concepts, you can drive the tool to produce results that may otherwise be challenging to obtain.  Use these types of techniques to produce your Mass Updates.  If you would like to work with professionals who have superior capacity to think and act with the NetSuite business platform, let’s have a conversation.

Marty Zigman LinkedIn

Marty Zigman

Holding three official certifications, Marty is widely recognized as a top NetSuite expert and leads a team of senior professionals at Prolecto Resources, Inc. A former Deloitte & Touche CPA and technology executive with CTO roles, he brings over 35 years of leadership in ERP, CRM, and eCommerce business systems. Contact Marty to engage directly.

BiographyYouTubeLinkedInX (Twitter)

18 thoughts on “How To: NetSuite Saved Search with List of Internal IDs

  1. Hi Marty,
    I use a similar trick but as a variation, if you use INSTR and search for the record ID within a list of the IDs you want, you can get more IDs within the character limit. All you need is a list of the ID values, split by a delimiter on both sides so that you don’t pick up partial IDs (so that looking for 9 doesn’t get a hit on 99 for example). Eg. INSTR(‘$123$124$127$129$134$’,’$’||{internalid}||’$’) is greater than 0

    Reply
  2. You can use an “OR” expression between criteria to group the IDs in to chunks that fit within the character limit – if there is a limit on the number of criteria lines,I’ve never come across it as the search will time out/not run long before you could reach it.

    Reply
  3. Hi Marty,

    is there any way to use this method with “Item Number/SKU”, when I try (and change the {internalid} with {name} I get an error.

    Reply
  4. I have a task with over 8,000 internal IDs to work with. So a big job to chunk down into sets of 1,000 characters. Is it possible to refer the formula to a text file containing all the IDs? And thanks for the article; has helped me a lot.

    Reply

Leave a Reply

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