Understanding NetSuite Script Parameters
💡 What are Script Parameters in NetSuite?
The term “parameters” can often confuse developers—especially those new to NetSuite. Many might assume it refers to the inputs passed into user-defined functions.
But in NetSuite, script parameters are custom fields used to control script behavior from the UI—without changing the script code itself. This makes scripts more configurable, maintainable, and less prone to hardcoding.
✅ Why Use Script Parameters?
🛠️ How to Create Script Parameters?
🎛️ How to Set Script Parameter Values?
The value source is based on where the parameter is configured:
While creating the parameter, there is a field called "Preference" which allows us to set the following preferences:
Company: If the "Company" preference is chosen, the parameter's value is read from the General preferences under the "Custom Preferences" subtab. It is important to note that this can be set only by the admins.
User: If the "User" preference is chosen, the parameter's value is read from Home>Set preferences under the "Custom Preferences" subtab. This value can be overridden by the users
Deployment: Default option. Value is set in the script deployment record.
💻 Accessing Script Parameters in Code
var runtime = require('N/runtime')
var myParam = runtime.getCurrentScript().getParameter({
Recommended by LinkedIn
name: 'custscript_myparam'
});
📧 Simple Use Case
Suppose you have a User Event script that sends an email notification whenever a new customer is created.
You want the ability to toggle this notification ON or OFF—without editing the script every time.
Solution: Create a Checkbox-type script parameter called custscript_send_email_alert.
var runtime = require('N/runtime')
var sendEmail = runtime.getCurrentScript().getParameter({
name: 'custscript_send_email_alert'
});
if (sendEmail)
{
// Code to send email
}
🔁 Bonus: Pass Data Between Scripts
Script parameters can also be used in script-to-script communication, such as when using the N/task module to schedule or trigger other scripts with dynamic values.
By using script parameters, you not only make your NetSuite scripts more flexible but also empower admins and end-users to make controlled adjustments without involving developers every time.
Thanks for sharing, Chandrakanth