Hi, hope you all are doing well. I am trying to ac...
# suitescript
s
Hi, hope you all are doing well. I am trying to access sublist in inventory details subrecord present on item receipt's Items sublist. But everytime I am getting an error
SSS_INVALID_FIELD_ON_SUBRECORD_OPERATION
I am getting field ids from records browser of netsuite. I am attaching the code snippet as well. Please any help in this matter would be very helpful.
var objSubRecord = objRecord.getSublistSubrecord({
                    
sublistId: 'item',
                    
fieldId: 'inventorydetail',
                    
line: i
                
});
                
var numLines2 = objSubRecord.getLineCount({
                    
sublistId: 'inventoryassignment'
                
});
                
for (var j = 0; j < numLines2; j++) {
                    
var lines = objSubRecord.selectLine({
                        
sublistId: 'inventoryassignment',
                        
line: j
                    
});
                    
var serialnumber = objSubRecord.getCurrentSublistValue({
                        
sublistId: 'inventoryassignment',
                        
fieldId: 'issueinventorynumber'
                    
});
                    
var serialnumber = objRecord.getSublistValue({
                        
sublistId: 'inventoryassignment',
                        
fieldId: 'issueinventorynumber',
                        
line: j
                    
});
b
remove
Copy code
var serialnumber = objRecord.getSublistValue({
  sublistId: "inventoryassignment",
  fieldId: "issueinventorynumber",
  line: j,
});
there is no inventoryassignment sublist on the item receipt
s
the inventory assignment sublist is on inventory details subrecord
b
objRecord is not an inventory detail
you should also be using
receiptinventorynumber
instead of
issueinventorynumber
s
Okay I will try that. Thanks alot.
b
im personally a little surprised that this doesnt fail at objSubRecord.selectLine
i was under the impression that subrecords are in standard mode
s
I have not tried it in standard mode. I will try that as well. Actually it was giving me the subrecord as well as number of lines present in that sub record perfectly but when I try to access the sublist lines it throws this error.
objRecord typo also does not seem to be the issue because the error is still in the subrecord api
I have also tried it in standard mode and it is giving the same error
b
what does your item receipt and inventory detail look like in the ui?
s
message has been deleted
b
that does look like advanced inventory management
what does the code you are trying look like now
s
Copy code
var objRecord = record.load({
                type: record.Type.ITEM_RECEIPT,
                id: itemrcpt,
                isDynamic: false,
            });
var objSubRecord = objRecord.getSublistSubrecord({
                    sublistId: 'item',
                    fieldId: 'inventorydetail',
                    line: i
                });
                var numLines2 = objSubRecord.getLineCount({
                    sublistId: 'inventoryassignment'
                });
                for (var j = 0; j < numLines2; j++) {
                    var serialnumber = objSubRecord.getSublistValue({
                        sublistId: 'inventoryassignment',
                        fieldId: 'receiptinventorynumber',
                        line: j
                    });
                    var Subrecordquantity = objSubRecord.getSublistValue({
                        sublistId: 'inventoryassignment',
                        fieldId: 'quantity',
                        line: j
                    });
                    dialog.alert({
                        title: 'Alert',
                        message: serialnumber
                    });
                }
b
assuming you have some code that properly set i and itemrcpt
that code works reasonably well for me
s
yes that is what I am facing right now.
b
I used
Copy code
require(["N/record", "N/ui/dialog"], function (record, dialog) {
  var objRecord = record.load({
    type: record.Type.ITEM_RECEIPT,
    id: 1651,
    isDynamic: false,
  });
  var objSubRecord = objRecord.getSublistSubrecord({
    sublistId: "item",
    fieldId: "inventorydetail",
    line: 0,
  });
  var numLines2 = objSubRecord.getLineCount({
    sublistId: "inventoryassignment",
  });
  for (var j = 0; j < numLines2; j++) {
    var serialnumber = objSubRecord.getSublistValue({
      sublistId: "inventoryassignment",
      fieldId: "receiptinventorynumber",
      line: j,
    });
    var Subrecordquantity = objSubRecord.getSublistValue({
      sublistId: "inventoryassignment",
      fieldId: "quantity",
      line: j,
    });
    dialog.alert({
      title: "Alert",
      message: serialnumber,
    });
  }
});
for me that displayed a bunch of alerts
s
@battk Thanks alot that worked perfectly. you were a great help. Thanks a million times