Nuri Ensing
Nuri Ensing

Reputation: 2030

validateInsert not getting triggered in Netsuite

I just started my journey with Suitescript 2.0 development. I have created a client script and attached it to an Opportunity. In the client script I have added a few simple console log statements like:

 function validateLine(context) {
    console.log('validateLine', context);
    alert("Line is changed!");
    return true;
}

/*
 * Execute code when field is changed
 */
 function fieldChanged(context) {
    console.log('fieldChanged', context);
}

function validateInsert(context) {
    console.log('validateInsert', context);
}

The validateLine + fieldChanged is working. However I can't seem to trigger the validateInsert function. I have tried everything, added a field, made a copy, saved the record but the validateInsert does not seem to be triggered because I am not getting any console logs.

How can I trigger the validateInsert?

My intention is to use the validateInsert trigger for the "Make Copy" button. The "Make Copy" button copies a line item. Validations are being made when copying a lineitem + the copied line item needs to get filled with specific data. If there is any advice or other tips, please let me know.

Upvotes: 1

Views: 673

Answers (1)

Sayeesh
Sayeesh

Reputation: 236

validateInsert is triggered/executed when you insert a line into edit sublist.

Whenever the user clicks the Insert button to add a new line above an existing one, a validateInsert event is fired.

EDIT -

As per my understanding of your requirement, I'd suggest to go for UserEvent Script with beforeLoad and VIEW context. (Assuming it is okay if changes are visible after you Make Copy and save the record).

ClientScripts being a Client-side script might cause performance issues if the number of lines are greater. So my opinion would be to go with UserEvent Script and you can setValues depending on the input data.

Give this a try. Let me know.

Upvotes: 1

Related Questions