used the validateLine function. When making a copy of a lineitem in Netsuite the lineitem field: “line” has an empty string value until the line is created by clicking the “Add” button or clicking outside of the copied lineitem. I will check if that field is empty, if yes it means the line is a copy.
function validateLine(context) {
try{
var currentRecord = context.currentRecord;
let lineNumber = currentRecord.getCurrentSublistValue({
sublistId: 'item',
fieldId: 'line'
});
if (lineNumber) {
//linenumber is existing this means line is not a copy
return true;
} else {
currentRecord.setCurrentSublistValue({
sublistId: 'item',
fieldId: 'custcol_jj_to_document_number',
value: null
});
return true;
//linenumber is empty this mean line is a copy
}
}catch(e){
log.debug("error@validateLine",e);
}
}