Referencing Script Parameters

You can use the Script.getParameter(options) method to reference script parameters that you create. This method is included in the N/runtime module, and you can use other methods in this module to work with scripts and script objects. For example, use runtime.getCurrentScript() to get a runtime.Script object representing your script. For more information, see N/runtime Module.

Before you can reference script parameters in your script, you must create them using the NetSuite UI. To learn how, see Creating Script Parameters. Remember the ID you used (or the ID that was generated automatically for you) when creating a script parameter. Use this ID in your script to get the script parameter's value.

The following example from a Suitelet obtains the value of a script parameter called custscript_mycheckbox:

          // Add a script parameter called Check Box Required
var myField = Form.addField({
    id: 'custscript_mycheckbox',
    label: 'Check Box Required',
    type: serverWidget.FieldType.CHECKBOX
});

// Obtain an object that represents the current script
var myScript = runtime.getCurrentScript();

// Obtain the value of the Check Box Required script parameter
var scriptParameterValue = myScript.getParameter({
    name: 'custscript_mycheckbox'
}); 

        

You cannot write to a script parameter using SuiteScript. You can read from these fields, but not write to them. You can pass a value to a script parameter outside of the UI only when you call task.create(options) to schedule a script.

For a complete example working with script parameters in a SuiteCloud project, see Disable Tax Fields.

General Notices