在我的預定腳本中,我循環遍歷項目實現時已轉換的銷售訂單上的項目,並嘗試設置庫存詳細信息。該庫存明細如下設置沒有任何錯誤或問題,但是當我嘗試保存我得到以下錯誤:無法設置項目實現記錄上的庫存詳細信息 - Suitescript 2
Please configure the inventory detail in line 2 of the item list.
兩線是需要在我的測試庫存明細的唯一項目。下面是代碼:
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();
提交清單的細節,如果我再檢查inventorydetail子記錄我可以看到,該行有相應的2號線和正確的項目之後。不知道爲什麼當我保存它說第2行需要庫存!
{"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":""}}}}
我已經嘗試過所有我能想到的組合,並且遵循套件回答文檔到發球臺。已嘗試在項目詳細信息/作業下的Netsuite記錄瀏覽器中設置每個值,並仍然出現此錯誤。非常感謝幫助/洞察力。
對不起,我應該提到這是一個預定腳本。 – Ryan
我已經爲原始問題添加了更多細節。非常感謝您的快速回復:) – Ryan