REQUIREMENT
Need to delete or remove the landed cost subrecord values in the item sublist when a copy of the record is taken.
SOLUTION
We can remove the landed cost subrecord values in a record when a copy of the record is taken. Add the below code snippet in the page init entry point of client script.
if (scriptContext.mode === 'copy') {
const currentRecord = scriptContext.currentRecord;
currentRecord.selectLine({
sublistId: 'item',
line: 0
});
currentRecord.removeCurrentSublistSubrecord({
sublistId: 'item',
fieldId: 'landedcost'
});
currentRecord.commitLine({
sublistId: 'item'
});
}
NB: This is not an efficient solution since the page will take more time to load if the no: of items are greater