There is a customized transaction line field which is named as "custcol_so_line_id". Its value should be the same as the ID of the sublist line.
The code is as follows:
function beforeSubmit(context) {
var rec = context.newRecord;
var lineItemID = rec.getSublistValue({
sublistId: 'item',
fieldId: 'id',
line: 1
});
rec.setSublistValue({
sublistId: 'item',
fieldId: 'custcol_so_line_id',
value: lineItemID
});
}
return {
beforeSubmit: beforeSubmit
}
After clicked the Save button in Sales Record. The sales record should display SO_12345 in the customized line field "cuscol_so_line_id". But it didn't and shows the error as follows:
load: Missing a required argument: id
for the code var salesRec = record.load({...
If I change the entry point to "afterSubmit", then the SO_12345 appears.
Can't we update the record before it is submitted? How to find the id for line in beforeSubmit
function?