I created a custom record which has parent record as Customer.
This custom record will have many lines, each line will store values of few fields.
I'd like to write a script to add new line to the custom record of a specific customer and set values to the fields of the new line.
Here is my custom record:
And here is my script:
var customerRecord = record.load({
"type": record.Type.CUSTOMER,
"id": customerId,
"isDynamic": true
});
customerRecord.selectNewLine({
sublistId: 'customrecord373'
});
customerRecord.setCurrentSublistValue({
sublistId: 'customrecord373',
fieldId: 'custrecord27',
value: 'test'
});
customerRecord.commitLine({
sublistId: 'customrecord373'
});
var recId = customerRecord.save();
And I got the error as below:
| SSS_INVALID_SUBLIST_OPERATION | 03/02/2020 23:06:12.741 |
| | {"type":"error.SuiteScriptError","name":"SSS_INVALID_SUBLIST_OPERATION","message":"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.","stack":["<anonymous>(N/record/recordService.js)","<anonymous>(adhoc$-1$debugger.user:14)","<anonymous>(adhoc$-1$debugger.user:1)"],"cause":{"type":"internal error","code":"SSS_INVALID_SUBLIST_OPERATION","details":"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.","userEvent":null,"stackTrace":["<anonymous>(N/record/recordService.js)","<anonymous>(adhoc$-1$debugger.user:14)","<anonymous>(adhoc$-1$debugger.user:1)"],"notifyOff":false},"id":"","notifyOff":false,"userFacing":false} |
Does anyone know how to add new line to the custom record which has the parent as Customer by SuiteScript 2.0?
I appreciate it.