Home » Deeper in to NetSuite » NetSuite Customization: Extracting Item Types from nlobjSearchRecord

NetSuite Customization: Extracting Item Types from nlobjSearchRecord


When working with the various item types (Inventory items, Non-Inventory items, Assembly items, Service items, etc.) supported by NetSuite. I’m sure you must have encountered scenarios where you have a list of internal item ids and you want to extract or fetch some of those items for use in some operation. For example, performing an update on the item record.

Now, when we use the nlapiSearchRecord command to extract items from a list of items, you always record the object type as ‘item’ (as shown below).

CTA - NetSuite Customization Banner

nlapiSearchRecord (‘item’,’internalid’,filters,columns);

But when you need to extract (fetch) or create items using the nlapiLoadRecord / nlapiCreateRecord commands, you need to specify the record type of the item you want, rather than just using the general term ‘item’, as shown below. Here:

nlapiLoadRecord(‘item’,’11111′) will not work 

but nlapiLoadRecord(‘inventoryitem’,’11111′) will work 


When you execute the nlapiSearchRecord command, it returns an array of nlobjSearchResult.

The nlobjSearchResult array has the ‘recordType’ property on the server and the ‘type’ property at the client end, and thus provides a record type that you can use in the nlapiLoadRecord function. For example:

CTA - NetSuite Implementation Banner

[code language=”javascript”]

var cols = [];
var recs;
var filters = [];
var itemInternalIds = [‘111’, ‘112’, ‘113’];
var currentItemLoaded;
filters.push(new nlobjSearchFilter(‘internalid’, null, ‘anyof’, itemInternalIds));
// Get List of Records
recs = nlapiSearchRecord(‘item’, null, filters, cols);
if(!!recs & recs.length > 0) {
for(var i = 0; i <recs.length; i++) {
currentItemLoaded = nlapiLoadRecord(recs[i].recordType, recs[i]); // Use recs[i].type for client script
// Further operations ……

// Further operations ……

// Further operations ……

As you can see, by using the solution above you can save the extra units involved in executing the nlapiLookupField/nlapiSearchRecord function, in order to fetch a specific item type. Of course if you use this call to load and process a large number of item records, then obviously it will be more resource intensive.

If you have a NetSuite customization requirement you would like to discuss, or would like to know more about our NetSuite customization services, please get in touch with us  

Get In Touch With Our Experts

    Get In Touch With Our Experts

      I have read and agree to the Privacy Policy of Folio3
      I agree to be contacted by Phone or Email by Folio3

      Get in touch with the


      End-to-end NetSuite Servicing Agency

      Tell us how may we assist you!