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();

 

 

 

 

yayinternets Rookie Asked on February 26, 2021 in SuiteScript.
Add Comment
3 Answers

First of all i am assuming you are not working for numbered items i.e serialized/lot numbered items .

In Dynamic Mode, sequence of value setting matters , so at line setting you should set the field in following sequence :

item,

location ,

adjustqtyby

 

Rookie Answered on March 3, 2021.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.