September 17, 2017

NetSuite’s Script and Deployment Records

In order for NetSuite to know how to utilize our SuiteScript source code, we need to be able to tell it which functions to call, when to call them, and who to call them for. We accomplish all of these with the Script and Script Deployment records.

Script Records

NetSuite uses the Script record to map the function(s) in your source file to specific events that occur in the system. For instance, if you need some business logic to run when a form is saved in the UI, the Script record will tell NetSuite which function to call when the saveRecord event occurs.

You can think of the Script record as defining when our source code should run; it essentially defines something akin to:

“When a record is saved, call the saveRecord function in hello-world.js.”

Here is an example of what that Script record would look like:

An example of a NetSuite Script record representing a Client Script that contains a function for handling the saveRecord event.

Script Deployment Records

Once we have a Script record created, we then need to deploy that script into the system. While the Script record tells NetSuite which functions to call from our source file, the Script Deployment record lets NetSuite know which records and users our Script should execute for.

While the Script record defines when our source code should run, the Script Deployment defines where and who can run our script. If we have a Script record that says:

“When a record is saved, call the saveRecord function in hello-world.js.”

then our Script Deployment for that record might modify that slightly to:

“When an Employee record is saved, call the saveRecord function in hello-world.js, but only for users in the Administrators group.”

Again, here is an example of what that Script Deployment would look like:

An example of a NetSuite Script Deployment record representing a Client Script deployed to the Employee record that will  only execute for users with the Administrator role.
{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

Related posts

March 3, 2021

Does the physical location of a competent employee change the amount of value they can deliver for your organization? If it does, I’d be keen to hear your story. If it does not, why ...

Read More

March 2, 2021

Today a friend and former colleague of mine – who happens to now be in a development leadership role for a NetSuite partner – was lamenting the extreme difficulty of finding and hiring NetSuite ...

Read More

March 1, 2021

Software is never finished; clients are always changing and re-prioritizing. NetSuite is ever a moving target – always updating and evolving. Market forces are always shifting and shoving, forcing new demands on your business. ...

Read More