Understanding NetSuite Script Parameters

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?

  • Configurability: Adjust script behavior directly from the UI—no code changes required.
  • Maintainability: Removes hardcoded values, making scripts cleaner and easier to manage.
  • Localization: Useful for defining values based on departments, subsidiaries, or languages.

🛠️ How to Create Script Parameters?

  • Open the script record (Client Script, User Event, Suitelet, etc.).
  • Go to the Parameters tab and click “New Parameter.”
  • Fill in the details such as the label, the data-type and the ID (most important to access these 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

  • You can retrieve script parameters using the runtime module

var runtime = require('N/runtime')

var myParam = runtime.getCurrentScript().getParameter({

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

To view or add a comment, sign in

Others also viewed

Explore content categories