Many of the tutorials in this series have been about the Client Script. If you have been following along, you should understand how to create and use client scripts in different basic scenarios. Now we can start touching on the basics of User Event scripts. When we are done going through use cases and scripting scenarios of User Event scripts, you should be able to create basic scripts on your own. Before jumping into an example User Event script, let’s take a look at the differences between Client Scripts and User Event scripts and when you should pick one over the other.

Client Script Vs. User Event Script

You can do some of the same things with both Client scripts and User Event scripts. So which one should you choose? Here are some basic differences that can help you decide which one to use for a customization.

  1. 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 the reason you can make it do something when you change 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.
  1. Performance and Speed
  • Client Scripts will only run as fast as your computer. Since they run in the browser, they are using 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 super computer, User Event Scripts will have a lower impact on overall performance than Client Scripts.
  1. 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 time a User Event Script can be triggered is when a record is loaded and when it is submitted. The Before Load trigger point runs when a record is loaded, and the Before Submit and After Submit triggers are available when the record is submitted.

Deciding Which Script To 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 script triggers to perform an action, use a User Event Script.
  • If you need to perform actions (especially if they are more complication actions) when loading or submitting a record, use a User Event Script.
Bonus Information

You may run into situations where you absolutely need to use a Client Script, but due to the amount of work the script is doing it results in a terrible lag when entering record information. There is a way to get rid of that lag that I will discuss in a future more advanced tutorial. There are also options to greatly improve the performance of complicated User Event Scripts.

    SuiteScript 2.0 Creating Pop-ups: The Dialog Module

    Creating custom pop-ups can be super helpful when implemented correctly. Our previous blog will help give you some ideas for your own use cases. Today we will walk you through creating your own. Having covered some of the foundational script types in SuiteScripting,...

    3 Reasons You Should Switch from SuiteScript 1.0 to 2.0

    There are many reasons to consider switching from SuiteScript 1.0 to 2.0. 3 reasons are modularity and compatibility with JavaScript and NetSuite’s APIs.

    SuiteScript 2.0 User Event Script After Submit

    In this blog we touch briefly on the 3rd and final User Event function that is available: the After Submit function. With this basic foundation of the structure and capabilities of each function, we will be ready to dive into some real life examples in the next...

    SuiteScript 2.0 User Event Script Before Submit

    In the last tutorial we looked at the setup of the Before Load trigger for User Event scripts. In this tutorial will introduce the basic setup of the 2nd of 3 main User Event triggers: the Before Submit trigger. I want to spend some time looking at each of these...

    SuiteScript 2.0 User Event Script Before Load

    User Event Scripts are one of the most common script types to work with. In the next several blogs I will walk through some example User Event scripts, and this first blog will introduce the basic setup of the Before Load trigger in a User Event script. Before Load...
    Would love your thoughts, please comment.x