Marty Zigman

Conversations with Marty Zigman

Certified Administrator • ERP • SuiteCloud

How to Search for NetSuite Inventory Detail Records

NetSuite Reporting Technical

Tags: ,

This article is for the NetSuite SuiteScript programmers who are need to search on NetSuite’s Inventory Detail Records.

Background

The NetSuite Inventory Detail is effectively a ledger structure that is used to manage Serial and Lot Control Numbers on inventory transactions.  Often times, there is a need to extend this record type.  For example, we created a custom serialized asset manager application that links up to NetSuite Inventory Detail record structure.  Accordingly, we needed to update the Inventory Detail record to produce linkages from NetSuite Work Order Assembly operations to the key in our custom application.

The challenge is that this area of the NetSuite API is not well documented which effectively “blinded” one of our senior consultants.  However, he pushed through it (we nearly always do) through trial and error and perseverance.  We present you the following.

SuiteScript Search Pattern to Find Inventory Detail Record InternalIDs

var func = "SomeSuiteScriptRoutine;"
var assemblybuildid = 12333 // reference assembly build record

var AB = nlapiLoadRecord("assemblybuild",assemblybuildid);
var INVDTL = AB.viewSubrecord("inventorydetail");

//hunt for related inventory detail records
filters = [];
columns  = [];
filters.push(new nlobjSearchFilter('internalid', null, 'is', INVDTL.getFieldValue("id")));
columns.push(new nlobjSearchColumn('internalid',"inventorynumber"));

results = nlapiSearchRecord('inventorydetail', null, filters, columns) || [];

var inventoryNumberId;
if (results.length > 0) {
	//in our case, we expect only one
	inventoryNumberId = results[0].getValue("internalid","inventorynumber");
	nlapiLogExecution("DEBUG", func, "Assembly Build references Inventory Number " + inventoryNumberId);
} else {
	obj = {};
	obj.error = 'Could not find Inventory Number linked to Assembly Build';
	nlapiLogExecution("ERROR", func, obj.error);
	return obj;
};

//with the inventoryNumberId in hand, we can now load it perform our updates

Come Work with Us

If you love the NetSuite platform yet you feel undervalued by others for your problem solving capacities, perhaps we can work together. Our clients value NetSuite based innovation and leadership. Are you ready to raise your standards, serve others, and grow your career? If so, 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)

27 thoughts on “How to Search for NetSuite Inventory Detail Records

  1. Hi,

    I tried to create a inventory transfer record from salesorder using suitescript.
    But when execute the script it displays the error “. ERROR: USER_ERROR – Please configure the inventory detail for this line.”.

    How we can configure it programatically?

    Could you please help me for this configuartion?

    Thanks

    Reply
  2. Hi ,
    My Problem is not solved. I want to set a serialized inventory item programaticaly using client. when i try to add an item into invoice, it shows the same error”please configure inventory detail for this line”.As per my knowledge i think we can’t create inventory detail in client script.how i can save this item without inventory detail.

    Could you please help me?

    Thanks,
    Rajitha K S

    Reply
  3. Hi,

    is it possible to add multiple serial numbers for particular item using nlapiSetCurrentLineItemValue(type,’serialnumbers’, lotnumber,false,false);?

    Reply
  4. Marty, sorry if this is not directly related to the topic, but how would you go about checking if the user has entered inventory detail on a TO item receipt via a client onsave script? I’ve tried >>>var invdetail = nlapiGetLineItemValue(‘item’,’inventorydetail’,i);<<< but get a nlobjError. I tried nlapiGetLineItemText but get null.

    This is confusing because "inventorydetail" is clearly on the item sublist according to the Record Browser (https://www.netsuite.com/help/helpcenter/en_US/srbrowser/Browser2016_2/script/record/itemreceipt.html).

    Thanks for your time.

    Reply
  5. I’m merely trying to verify the user has entered inventory detail on a TO receipt. NetSuite does this by putting a green check mark on the inventory detail icon. Is it possible to check for the green check?

    Reply
  6. Marty, I actually went a different route: view page source 🙂

    I sifted through the page source code and grabbed what I needed to make my onsave script run as follows:

    var linecount = nlapiGetLineItemCount('item'); for(i=1; i <= linecount; i++){ nlapiSelectLineItem('item', i) var itemtext = nlapiGetLineItemValue('item', 'item', i) try{ var invdetail_avail = nlapiGetCurrentLineItemValue('item', 'inventorydetailavail') var invdetail = nlapiViewCurrentLineItemSubrecord('item','inventorydetail'); var invdetail_linecount = invdetail.getLineItemCount('inventoryassignment'); for(var j = 1; j <= invdetail_linecount; j++){ invdetail.selectLineItem('inventoryassignment', j) var binnumber = invdetail.getCurrentLineItemValue('inventoryassignment', 'binnumber') var binqty = invdetail.getCurrentLineItemValue('inventoryassignment', 'quantity') console.log(invdetail_avail + ' ' + invdetail + ' ' + binnumber + ' ' + binqty) } }catch(err){ console.log(err) } }
    Reply
  7. Hi Marty,

    I want to fill/insert the inventory details in item fulfillment page using suitescript. Since I can’t create subrecord inventory detail with client script, I want using user event before submit script but the problem is when i click Save button there is alert that display i need to configure inventory details in line-i. Can you give me your suggestion how to handle this?Thank you before.

    Reply
  8. Hi Marty,

    Thanks for your answer. I just want to make sure if your answer can use for sublist subrecord? I need to fill the inventory detail for all items in Item Fulfillment/shipment page.

    And i read in your comment before that inventory details can’t edit in client script.

    Thank you

    Reply
  9. Marty been following you for years hoping you can help!

    I have custom “item number” fields for things like version and firmware since NS doesn’t have version control. I want users to enter that info on the inventory detail when receiving or assembling. Is it possible to script the inventory detail to allow users to enter that info in the native Inventory detail screen? The only thing I have found to work is setting on custom fields on the transaction line and an after-submit script to update the Lot Number after saving the receipt.

    Reply
  10. Hi Marty,

    Thanks for this SS1 script. I rewrote it in SS2 but I get this error: “Your search contains a reference to join for which you do not have a permission: InventoryNumber”

    Any idea what permission I need?

    P.S. In attempt to discover the permission I tried a search of type search.Type.INVENTORY_NUMBER and got an error saying I needed Lists > Items but after adding that and retrying the original join-ed search I still get the same error.

    P.P.S. Here’s the essence of my SS2 version:
    const searchObj = search.create({
    type: search.Type.INVENTORY_DETAIL,
    filters: [
    search.createFilter({
    name: ‘internalid’,
    operator: search.Operator.IS,
    values: inventoryToEquipment.invDetailId
    })
    ],
    columns: [
    search.createColumn({
    name: ‘internalid’,
    join: search.Type.INVENTORY_NUMBER
    })
    ]
    });

    Reply

Leave a Reply

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