Creating Script Parameters Overview
In the context of SuiteScript, script parameters are similar to custom fields; they are not considered to be parameters that are passed between JavaScript functions. A script parameter can have any of the characteristics of a custom field created through point-and-click customization. Script parameters are configurable by administrators and the users of your Suite App, and are accessible programmatically through SuiteScript. Script parameters are defined on the Parameters tab of the Script record page.
Do not include confidential information in script parameters. Information saved in script parameters can be indexed by search engines and therefore be viewable by the public. This means, for example, that the information could be found in Google searches.
You should create script parameters in the following situations:
-
You want part of your script to be configurable, either through script deployment or by the users of your SuiteApp. You do not need to create script parameters if your script is not designed to be configurable.
-
You need to parameterize a script that was deployed multiple times. This approach makes it more convenient to customize the behavior of the script for each deployment.
-
You want to configure a scheduled script. You can configure scheduled scripts by specifying the configuration parameters as arguments to task.create(options).
The advantages of using script parameters include:
-
Deployment-specific parameters let you configure script behavior without having to write code. These parameters are useful when administrators deploy scripts that were installed as part of a bundle. The parameters allow administrators to control or modify the script without knowing anything about the code. Deployment-specific parameters are similar to property or configuration files that some applications use to modify behavior at runtime.
-
Script parameters let you modify script behavior for troubleshooting purposes without having to change code, which is often expensive and not feasible (for example, if the original script author is unavailable).
-
Script parameters give you the flexibility to handle a wide range of inputs depending on the context. For example, consider a situation in which one script is deployed to 50 different records, but requires slightly different behavior for each record. You could hard-code and deploy 50 different scripts, but they may be difficult to maintain because the code is not configurable, code might be duplicated unnecessarily, and changes in business requirements likely require code changes.
For more information, see the following help topics: