We created a suitescript 2.0 script in our netsuite environment. We are using RESTlet to access it.
Our script creates a sales order with various fields. It works fine but we are unable to set a coupon code value or a partner code, we get the same error for both. We are using Internal ID and we tried coupon code itself as well.
Any idea?
Error:
{
"type":"error.SuiteScriptError",
"name":"INVALID_FLD_VALUE",
"message":"You have entered an Invalid Field Value 18 for the following field: couponcode",
"stack":[
"<anonymous>(N/record/recordService.js)",
"setSalesOrderData(adhoc$-1$debugger.user:71)",
"saveSaleOrder(adhoc$-1$debugger.user:17)",
"<anonymous>(adhoc$-1$debugger.user:107)",
"<anonymous>(adhoc$-1$debugger.user:6)"
],
"cause":{
"type":"internal error",
"code":"INVALID_FLD_VALUE",
"details":"You have entered an Invalid Field Value 18 for the following field: couponcode",
"userEvent":null,
"stackTrace":[
"<anonymous>(N/record/recordService.js)",
"setSalesOrderData(adhoc$-1$debugger.user:71)",
"saveSaleOrder(adhoc$-1$debugger.user:17)",
"<anonymous>(adhoc$-1$debugger.user:107)",
"<anonymous>(adhoc$-1$debugger.user:6)"
],
"notifyOff":false},"id":"","notifyOff":false
}
}
RESTlet code:
var objRecord = record.create({
type: record.Type.SALES_ORDER,
isDynamic: true
});
/* add other values.....*/
objRecord.setValue({ fieldId: 'couponcode', value: 538 });
var recordId = objRecord.save({
enableSourcing: false,
ignoreMandatoryFields: false
});