First load the record in dynamic mode.
To select the new line at the end of a sublist in any record we can use,
record.selectNewLine(options).
After selecting the new line in sublist, set the sublist value using,
objRecord.setCurrentSublistValue(options).
Then to commits the currently selected line on the sublist use,
objRecord.commitLine(options)
Finally save the record.
Example code of estimate record is added below.
var objRec = record.load({
type: record.Type.ESTIMATE,
id: estimateid,
isDynamic: true,
});
objRecord.selectNewLine({
sublistId: 'item'
});
objRecord.setCurrentSublistValue({
sublistId: 'item',
fieldId: 'item',
value: true,
ignoreFieldChange: true
});
objRecord.commitLine({
sublistId: 'item'
});
objRec.save()