Within my scheduled script I am looping through the items on a transformed Sales Order to Item fulfillment and trying to set the inventory detail as I am looping through the items. The Inventory detail looks to set without any error or issue but when I try to save I get the following error:
Please configure the inventory detail in line 2 of the item list.
Line two is the only item that requires inventory detail in my test. Here is the code:
var itemFulfillment = record.transform({
fromType: record.Type.SALES_ORDER,
fromId: salesOrder.fields.id,
toType: record.Type.ITEM_FULFILLMENT,
isDynamic: true
});
var lineCount = itemFulfillment.getLineCount({ sublistId: 'item' });
for (var i = 0; i < lineCount; i++) {
itemFulfillment.selectLine({
sublistId: 'item',
line: i
});
var remainingQty = itemFulfillment.getCurrentSublistValue({
sublistId: 'item',
fieldId: 'quantityremaining'
});
itemFulfillment.setCurrentSublistValue({
sublistId: 'item',
fieldId: 'quantity',
value: remainingQty
});
var inventoryDetail = itemFulfillment.getCurrentSublistValue({
sublistId: 'item',
fieldId: 'inventorydetailreq'
});
var binItem = itemFulfillment.getCurrentSublistValue({
sublistId: 'item',
fieldId: 'binitem'
});
if (inventoryDetail === 'T' && binItem === 'T') {
var inventoryDetailRecord = itemFulfillment.getCurrentSublistSubrecord({
sublistId: 'item',
fieldId: 'inventorydetail'
});
inventoryDetailRecord.selectNewLine({
sublistId: 'inventoryassignment'
});
inventoryDetailRecord.setCurrentSublistValue({
sublistId: 'inventoryassignment',
fieldId: 'issueinventorynumber',
value: 10154 // I know this is the serial number record internal ID for my test
});
inventoryDetailRecord.setCurrentSublistValue({
sublistId: 'inventoryassignment',
fieldId: 'quantity',
value: 1 //Again I know this so hard coded for testing
});
inventoryDetailRecord.commitLine({
sublistId: 'inventoryassignment'
});
}
}
var ifRecordId = itemFulfillment.save();
After committing the Inventory detail if I then check the inventorydetail sub record I can see that the line is there corresponding to line 2 and the correct item. Not sure why when I save it says line 2 needs inventory!
{"type":"inventorydetail","isDynamic":true,"fields":{"itemdescription":"160W PREMIUM GRADE","nlloc":"0","nlsub":"1","trandate":"4/20/2017","_eml_nkey_":"0","type":"inventorydetail","subrecord_parent_tran_type":"ItemShip","nsapiCT":"1492728327986","sys_id":"-19281976277926580","nluser":"-4","nldept":"0","subrecord_transform_from_parent_id":"305887","subrecord_transform_from_parent_tran_type":"SalesOrd","tolocationusesbins":"F","item":"3312","quantity":"1.0","sys_parentid":"19281975969964536","templatestored":"F","entryformquerystring":"orderline=2&unit=&item=3312&quantity=1&subrecord_transform_from_parent_id=305887&trandate=4/20/2017&location=25&uitype=LOH_STRICT_VALIDATION&subrecord_transform_from_parent_tran_type=salesord&subrecord_parent_tran_type=itemship","nlrole":"3","uitype":"LOH_STRICT_VALIDATION","baserecordtype":"inventorydetail","baseunitquantity":"1.0","totalquantity":"1","orderline":"2","haslines":"T","tolocation":"-1","customform":"-10820","location":"25"},"sublists":{"inventoryassignment":{"currentline":{"binnumber":"","binnumber_display":"","existinginventorynumber":"","expirationdate":"","internalid":"-1","inventorydetail":"-1","issueinventorynumber":"","lotquantityavailable":"","quantity":"1","quantityavailable":"","receiptinventorynumber":"","sys_id":"-19281976361182898","sys_parentid":"-19281976277926580","tobinnumber":"","tobinnumber_display":"","#":"2"},"line 1":{"binnumber":"25","binnumber_display":"","existinginventorynumber":"10154","expirationdate":"","internalid":"10154.0","inventorydetail":"-1","issueinventorynumber":"10154","lotquantityavailable":"","quantity":"1.0","quantityavailable":"","receiptinventorynumber":"1793064_3312_NA","sys_id":"-19281976302211623","sys_parentid":"-19281976277926580","tobinnumber":"","tobinnumber_display":""}}}}
I have tried every combination I can think of and followed the suite answer docs to a tee. Have tried setting every value in the Netsuite Records Browser under Item Details / Assignment and still get this error. An help/insight is greatly appreciated.