So, i'm trying to create a Item Receipt on my NetSuite instance using SuiteScript 1.0, and i'm receiving this error message:
{\"success\":false,\"errorMessage\":\"\\nCode: SSS_INVALID_SUBLIST_OPERATION\\nDetails: You have attempted an invalid sublist or line item operation. You are either trying to access a field on a non-existent line or you are trying to add or remove lines from a static sublist.\"}"
So, i do not understand a lot of NetSuite, but i think static lists can't be modified. If that's the case, then how am i supposed to create a Item Receipt through SuiteScript if i can't add the items?
Below are my scripts, and the Postman Json request that i'm using:
SuiteScript:
function createItemReceipt(dataIn) {
try {
var record = nlapiCreateRecord('itemreceipt', {recordmode: 'dynamic'});
record.setFieldValue('entity', dataIn.entity);
for (var i = 0; i < dataIn.items.length; i++) {
var item = dataIn.items[i];
record.selectNewLineItem('item');
record.setCurrentLineItemValue('item', 'item', item.itemId);
record.setCurrentLineItemValue('item', 'quantity', item.quantity);
record.commitLineItem('item');
}
var recordId = nlapiSubmitRecord(record, true, true);
return {
success: true,
recordId: recordId
};
} catch (e) {
return {
success: false,
errorMessage: e.toString()
};
}
}
function post(dataIn) {
var response = createItemReceipt(dataIn);
return JSON.stringify(response);
}
Json payload:
{
"entity": "123",
"items": [
{
"itemId": "456",
"quantity": 10
},
{
"itemId": "789",
"quantity": 5
}
]
}