RE: “UNEXPECTED_ERROR” for Inventory Adjustment
I am getting an Unexpected Error message when I try to script a very simple inventory adjustment. I tried this both in server and client, and I tried both isDynamic=true and false, but I’m still getting the same error.
I am able to create an inventory adjustment on thru UI with no problems with the current values I’m scripting.
Can anyone eyeball possibly what I’m doing wrong? I have been able to script adjustments in the past so I’m hoping it’s a simple fix. Thank you!
isDynamic = true:
var oInventoryAdj = record.create({ type: record.Type.INVENTORY_ADJUSTMENT, isDynamic: true, });
oInventoryAdj.setValue({fieldId: 'memo', value: "February Adjustments", });
oInventoryAdj.setValue({fieldId: 'trandate', value: new Date("02/26/2021"), });
oInventoryAdj.setValue({fieldId: 'account', value: 249, });
oInventoryAdj.insertLine({sublistId: 'inventory', line: 0 });
oInventoryAdj.selectLine({sublistId: 'inventory', line: 0 });
oInventoryAdj.setCurrentSublistValue({ sublistId: 'inventory', fieldId: 'location', line: 0, value: '1', });
oInventoryAdj.setCurrentSublistValue({ sublistId: 'inventory', fieldId: 'item', line: 0, value: '1495', });
oInventoryAdj.setCurrentSublistValue({ sublistId: 'inventory', fieldId: 'adjustqtyby', line: 0, value: '7', });
oInventoryAdj.commitLine({ sublistId: 'inventory', line: 0, });
oInventoryAdj.save();
isDynamic = false
var oNetsuiteTransactionObject = record.create({ type: record.Type.INVENTORY_ADJUSTMENT, isDynamic: false, });
oNetsuiteTransactionObject.setText({fieldId: 'memo', text: "February Adjustments", });
oNetsuiteTransactionObject.setValue({fieldId: 'account', value: 249, });
oNetsuiteTransactionObject.setSublistValue({ sublistId: 'inventory', fieldId: 'location', line: 1, value: '1', });
oNetsuiteTransactionObject.setSublistValue({ sublistId: 'inventory', fieldId: 'item', line: 1, value: '1495', });
oNetsuiteTransactionObject.setSublistValue({ sublistId: 'inventory', fieldId: 'adjustqtyby', line: 1, value: '7', });
oNetsuiteTransactionObject.save();
Are you using serialized inventory? If so you may need o add the inventory detail for he adjustment as well. SuiteAnswers 61069.
…
inventoryDetailSubrecord = rec.getSublistSubrecord({
sublistId: ‘item’,
fieldId: ‘inventorydetail’,
line: 0
});
……
subrecordInvDetail.setSublistValue({
sublistId: ‘inventoryassignment’,
fieldId: ‘receiptinventorynumber’,
line: 0,
value: ‘012345’
});
…
Also there is SuiteAnswer 94552 with the same error you have. Solution is to check hat there are not ay customizations setting the Location in he man body field
Dext3r
Hello, I see this is a very old post but I had this issue recently. This thread showed up on google and I managed to solve it for my use case.
This SuiteAnswer lead me to the answer.
Creating Inventory Adjustments via SuiteScript Returns Unexpected Error
Manually setting adjlocation solved the issue for me.