When creating a new sales order in Suitescript and setting a sublist value for item, an error of INVALID_FLD_VALUE is thrown.
The value I'm passing is the internal id for the item, I have tried with multiple items' internal ids, both with and without quotes and receive the same error. Code is below
/**
* @NApiVersion 2.0
* @NScriptType Restlet
* @NModuleScope SameAccount
*/
define(['N/record'], function (r) {
function get(context) {
try {
// Create new record type of SALES_ORDER
var salesOrder = r.create({
type: r.Type.SALES_ORDER,
isDynamic: false,
defaultValues: null
})
// CREATE AN ITEM AND SET VALUES
salesOrder.insertLine({
sublistId: 'item',
line: 0
});
// Item Intetrnal ID
salesOrder.setSublistValue({
sublistId: 'item',
fieldId: 'item',
line: 0,
value: '15'
});
// Quantity
salesOrder.setSublistValue({
sublistId: 'item',
fieldId: 'quantity',
line: 0,
value: 4
});
salesOrder.save();
return JSON.stringify('Sales Order Created');
}
catch (err) {
log.audit({
title:'Error',
details: err
})
return JSON.stringify(err);
}
}
return {
get: get
}
})
I have seen tutorials written with this code almost line for line, making me wonder if this has to do with a feature or setting in NetSuite that needs to be turned on/off. Any feedback is greatly appreciated.