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:
A Script can have multiple Script Deployments associated to it. This allows us to deploy the same business logic to multiple different record types with varying audiences.