DIFFERENCE BETWEEN CLIENT SCRIPT SAVE FUNCTION AND USER EVENT BEFORE SUBMIT FUNCTION?

A lot of times validation is required on submit of a record and developers can get confused on whether to use client script save function or user event before submit function to perform the validation. The below points can be used to make an informed decision.


TRIGGER POINT:

Client script save is triggered only on create, edit and copy.

User event before submit is triggered on create, edit, delete, xedit, approve, reject, cancel (SO, ER, Time Bill, PO & RMA only), pack, ship (IF), markcomplete (Call, Task), reassign (Case), editforecast (Opp, Estimate)

Also user event before submit has a type parameter to check the trigger type. Client script save function doesn't have any parameter. To check the trigger type in client script, you will need a pageinit function as well which can be used to copy the type to a global variable which can be accessed on save.


USER PERMISSION:

A client script can triggered only based on the role permission of logged in user.  Hence, if you are trying to access or  create any record, then users who trigger the script must have the permission for that record.

User event script can be deployed to execute in any role. It can be executed in Admin role to prevent any issues related to user permission.

EXECUTION CONTEXT:

A client script save function is triggered only when record is saved via UI.

A user event script can trigger when record is saved via UI, Webstore, other scripts (except

UE), CSV etc.

JAVA SCRIPT FUNCTIONS:

Client script can be useful when some of the javascript functions like alert, prompt, docuemnt,getElementById() etc needs to be used.

User event script before submit can't be used for giving alert or prompt.


PREVENTING RECORD SAVE

Record can be prevented from being saved based on certain validations by returning false from client script save function.

User event before submit functions will have to throw error using createerror api to prevent user from submitting the record.

DEPLOYMENT

Client script can be deployed on Netsuite record, forms and can also be attached to suitelet scripts.

User event scripts can be deployed only on Netsuite records.


SERVER SIDE API'S

Client script cannot be used to used to execute server side api's like scheduling api's, file api's etc. A backend suitelet will have to be called from client script to perform these actions.

User event before submit function function can make use of all the server side api's.


Note: A user event before submit is usually preferred ahead of client save unless you want to throw an alert or prompt.

contact us at:
Email : info@smilingcoders.com





Comments

  1. We are NetSuite Solution Provider with vast experience in NetSuite Implementation, netsuite customization including netsuite training & netsuite integration.
    NetSuite Solution Provider
    NetSuite Training
    NetSuite Implementation
    NetSuite Customization
    NetSuite Integration

    ReplyDelete

Post a Comment

Popular posts from this blog

Work Around the 1000 Row Limit Returned by Saved Searches in Netsuite

Understand Core Technology behind SuiteScript 2.0

HOW TO SET SUBLIST SUB RECORD VALUES IN SUITE SCRIPT 1.0 AND 2.0