Reputation: 935
I am trying to create a customer in SuiteScript using the below code.
var customer = record.create({
type: record.Type.CUSTOMER,
isDynamic : true
}).setValue({
fieldId : 'firstname',
value : eOrder.bill_firstname
}).setValue({
fieldId : 'lastname',
value : eOrder.bill_surname
}).setValue({
fieldId : 'email',
value : eOrder.customer_email.replace(/\s+/g, '')
}).setValue({
fieldId : 'phone',
value : phoneNumber
}).setValue({
fieldId : 'leadsource',
value : LEAD_SOURCE_ECOMM
});
var customerId = customer.save();
When the script runs this line I am getting the following error.
{
"type": "error.SuiteScriptError",
"name": "SSS_MISSING_REQD_ARGUMENT",
"message": "load: Missing a required argument: id",
"stack": [
redacted
],
"cause": {
"type": "internal error",
"code": "SSS_MISSING_REQD_ARGUMENT",
"details": "load: Missing a required argument: id",
"userEvent": null,
"stackTrace": [
redacted
],
"notifyOff": false
},
"id": "",
"notifyOff": false,
"userFacing": false
}
Since the customer is being saved I do not understand why I am getting a load error? The record is getting created fine, but the script can't continue due to this error?
Upvotes: 2
Views: 3494
Reputation: 180
Alternate cause of the problem
For anyone whose problem wasn't solved by the selected answer, another probable cause could be a field linked to another record. If this field is empty when you save the record, it throws the same error as that field is also expecting an ID for the related record.
That was the case for me.
Upvotes: 0
Reputation: 8847
It's likely there is a script running on beforeLoad
of the Customer record that's looking for the ID of the Customer, which doesn't exist yet when you are creating the record.
You'll want to look at the Scripted Records page for the Customer record and investigate any User Event scripts that run on the beforeLoad
trigger. Any code there that relies on the ID of the record existing should not be running on CREATE
.
Upvotes: 3