Where the script runs:
- Clients Scripts run in the browser. That means when you load a record the client script starts to run, and it is immediately available to perform actions when you click around on the record. That is why you can make it do something when changing a field.
- User Event Scripts run on the server. Unlike a Client Script, the User Event Script is not immediately available when you load a record because it runs on the server, not the browser.
Performance and Speed:
- Client Scripts will only run as fast as your computer. Since they run in the browser, they use your computer’s resources to do the work. So if you have a generally slow computer a client script will run slowly.
- User Event Scripts run faster than Client Scripts. Since User Event Scripts run on NetSuite’s server, they have access to more powerful resources. That means unless all your users have a supercomputer, User Event Scripts will have a lower impact on overall performance than Client Scripts.
Trigger Points:
- Client Scripts have 10+ trigger points. Since Client Scripts are immediately available to perform actions as you change fields and add lines, there are a lot of trigger points to choose from.
- User Event Scripts have 3 trigger points. The only times a User Event Script can be triggered are when a record load and when submits. The Before Load trigger point runs when the record loads, and the Before Submit and After Submit triggers are available when the record submits.
How to determine which script should use?
Based on the differences mentioned above, there is a basic thought process I go through to determine whether to use a Client Script or a User Event Script.
- If an action needs to be performed as fields are changed or lines or added, the only option is to use a Client Script.
- If you need to prevent a user from saving the record if conditions are met, use a Client Script.
- If you do not absolutely need one of the client scripts triggers to perform an action, use a User Event Script.
- If you need to perform actions (especially if they are more complicated actions) when loading or submitting a record, use a User Event Script