Hey guys, I have a client script on a custom form,...
# suitescript
c
Hey guys, I have a client script on a custom form, which also displays a sublist of related child records (also custom records). All of my hooks seem to work, except for “Validate Insert”. I’m trying to prevent new lines from being added, however, adding a line to the sublist doesn’t even trigger a call to the function. Any idea why? The “Validate insert” is even picked up by the script itself
Copy code
function validateInsert(scriptContext) {
    console.log("validateInsert was called!")
    return true
}
return {
    fieldChanged: fieldChanged,
    validateField: validateField,
    validateInsert: validateInsert
};
e
Does it happen to be a 2.1 script?
c
yes.. and actually I just realize the function does get called when I click the “Insert” button, but NOT when I click the “Add” button
e
I think you're wanting the Validate Line function. I believe that runs on; Insert, Add, and Remove
c
It does, but it also runs any time a field is edited, and I’m not sure how to distinguish between a line being added vs edited
r
You can use the line init event to get a specific value on the sublist and store that in a global variable. then on your validate line event, you can check if the global variable has a value, if it does not then it is a new line. Other than that, I don't think there is a way to distinguish new lines from edited lines.
Validate Insert is triggered when you click on the insert button on the UI