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

January 7, 2021

Anything I wrote today about business would both feel and be inadequate. I simply can’t arrive at the words to express how I feel in this moment. So instead, here are a few helpful ...

Read More

December 20, 2020

2020 was a hundred swift kicks to the shorts and one giant kick in the ass. If you’ve lost people you love, if you’ve gotten sick or hurt, if you’ve lost your job, if ...

Read More

December 16, 2020

“I’ve been meaning to learn SuiteScript, but it’s hard to find the time …”“We’re slammed, and I just don’t have the time …”“I haven’t made the time …” All are variations of a theme ...

Read More

December 14, 2020

Last week we looked at mimicking the functionality of a REST endpoint with its own module (e.g. retrieving a User, or a list of Users, refreshing a token, etc). For complex integrations that rely on a large ...

Read More