NetSuite SuiteScript 2.0 Lookup Hard-to-Search Values

This article is relevant if you are using NetSuite and you are having trouble getting to data that is not part of the standard record sets.

Background

Not all NetSuite records are exposed to the API in a standard fashion. A great example is the state and country list. See my article Download NetSuite JavaScript Country and State Lookups. You certainly can create a list of that data and maintain it in your code. But there may be a better way.

The Technique to get to NetSuite Hard to Find Information

The trick for getting to hard-to-search NetSuite data is to perform server-based memory-only record functions leveraging NetSuite’s rich model to hold metadata. The idea is to perform a record function that will not be committed but that will instead give you the data you need in your real work.

Example SuiteScript 2.0 for Looking Up Ship Status values

Below is a code snippet example that illustrates the technique.

//if the record supports create (record.create), use that approach; no record identifier required;
//but the following examples are more interesting.  Make sure that the record is in dynamic mode.

var rec = record.transform(
	{fromType: 'salesorder'
	,fromId: 489141
	,toType: 'itemfulfillment'
	,isDynamic: true}
);

//alternatively, load an existing itemfulfillment
var rec = record.load({type: 'itemfulfillment', id: 23911941, isDynamic: true});

//request data of the dropdown field that has the information you need
var opts = rec.getField({fieldId: 'shipstatus'}).getSelectOptions();

/*
JSON output of the opts object
[ 
	{
		"value": "A",
		"text": "Picked"
	},
	{
		"value": "B",
		"text": "Packed"
	},
	{
		"value": "C",
		"text": "Shipped"
	}
]

*/

Solve your NetSuite Enhancement Challenges

Don’t let built-in NetSuite features and documented APIs get in the way of your needed software solution. Contact us if you are ready to push NetSuite even farther to solve your real business requirements.

Be Sociable, Share!

Marty Zigman

Holding all three official certifications, Marty is Southern California's 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 25 years, Marty has produced leadership in ERP, CRM and eCommerce business systems. Contact Marty to setup a conversation.

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

| Category: NetSuite | Leave a comment

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>