Search code examples
javascriptfor-loopnetsuitesuitescript

How to get the lot number from inventory details column in line table(in Netsuite)?


i need to print the values of lot number in the inventory detail line field which is actually a small icon, when i hit it, it opens a small window that has line items. i just need to print them on my Suitelet printout.

i tried to run this loop but its printing the value(lot number) of the first line but for the other lines its showing NULL. enter image description here

var countitem=invAdjRec.getLineItemCount('inventory');
for (var c1=1;c1<=countitem;c1++)
{
invAdjRec.selectLineItem('inventory',c1);
var invDet = invAdjRec.getCurrentLineItemValue('inventory','inventorydetailavail');
var text="";
if (invDet == 'T')
{
var rec= invAdjRec.viewLineItemSubrecord('inventory', 'inventorydetail',c1);
var invcount = rec.getLineItemCount('inventoryassignment');
nlapiLogExecution('debug','invcount',invcount)
for(var xx = 1; xx <=invcount ; xx++) 
{
rec.selectLineItem('inventoryassignment', xx);
var idLot= rec.getLineItemText('inventoryassignment', 'issueinventorynumber',xx);
nlapiLogExecution('debug','idLot',idLot+':'+ xx)
text = text + 'Lot Number: ' + idLot + '\n';
}
}
}

This is my printout


Solution

  • Try this:

    var idLot = rec.getCurrentLineItemValue('inventoryassignment', 'receiptinventorynumber');
    

    Just tried that on one of my account and works fine.