Nbtwist
05/16/2023, 7:01 PM{
"type": "error.SuiteScriptError",
"name": "USER_ERROR",
"message": "Please enter value(s) for: Company",
"stack": [
"Error\n at RecordInvoker.save (suitescript/resources/javascript/record/serverRecordService.js:371:13)\n at NetSuiteObject.thenableFunction() (suitescript/resources/javascript/record/proxy.js:115:24)\n at <http://Object.post|Object.post> (/SuiteScripts/update_create_opp.js:34:39)"
],
"cause": {
"type": "internal error",
"code": "USER_ERROR",
"details": "Please enter value(s) for: Company",
"userEvent": null,
"stackTrace": [
"Error\n at RecordInvoker.save (suitescript/resources/javascript/record/serverRecordService.js:371:13)\n at NetSuiteObject.thenableFunction() (suitescript/resources/javascript/record/proxy.js:115:24)\n at <http://Object.post|Object.post> (/SuiteScripts/update_create_opp.js:34:39)"
],
"notifyOff": false
},
"id": "",
"notifyOff": false,
"userFacing": true
}
Code is simple:
/**
*@NApiVersion 2.1
*@NScriptType Restlet
*/
// Script to handle incoming data from the website and create/update the opportunity in netsuite
define(["N/record"], function (record) {
// POST the record
function post(context) {
// Check if ns_is field contains none
log.debug("context", context);
try {
if (!context.hasOwnProperty("id")) {
// Create an opportunity in netsuite
var object = record.create({
type: record.Type.OPPORTUNITY,
isDynamic: false
});
} else {
// Update the opportunity in netsuite
var object = record.load({
type: record.Type.OPPORTUNITY,
id: context["id"],
isDynamic: false
});
}
for (var key in context) {
object.setValue({
fieldId: key,
value: context[key],
ignoreFieldChange: true
});
}
var objectId = object.save();
log.debug("Object ID", objectId)
return {
"id": objectId
};
} catch (e) {
log.error("Error", e);
}
return {
"id": objectId
};
}
return {
post: post
};
});
The payload is as follows:
{
"subsidiary": "2",
"type": "opprtnty",
"title": "Finally Testing!! 3",
"custbodyhubspot_id": "13235544938",
"salesrep": "27895",
"custbody_industry_type": 20,
"custbody_inside_salesrep_trans": "9060",
"custbody26": true,
"id": "48979224",
"entity": "50481",
"custbody__bbs_oppstate": 2,
"custbody_territoryorigin": 1
}
Anyone have any thoughts to why this is erroring?