ANS-0861 · SUITESCRIPT DEVELOPMENT

How to Reset a NetSuite Scheduled Script Parameter Daily?

Learn how NetSuite Scheduled Script parameters behave and implement a reliable daily reset mechanism for values.

Short answer

NetSuite Scheduled Script parameters are not persistent across runs. To ensure a daily reset, configure the parameter's default value to 0 on the script deployment. Alternatively, implement logic within the script to check for a condition and reset the parameter's effective value to 0 at the start of each execution.

Scenario

A NetSuite user requires a Scheduled Script (SSC) that runs nightly to have a specific script parameter (e.g., an Integer holding a timestamp) reset to 0 at the beginning of each daily execution. While manual execution methods allow for parameter adjustment, the challenge lies in automating this reset for nightly scheduled runs.

Solution

NetSuite Scheduled Script parameters are not inherently persistent across different executions. When a script is scheduled, any parameter values passed are specific to that particular run and do not permanently alter the parameter's default configuration on the script deployment. This means that if a parameter is not explicitly passed a value during a script execution call (e.g., when using task.create() from the N/task module to schedule a script), it will revert to its default value configured on the script deployment.To achieve a daily reset of a script parameter to 0, consider the following approaches:

  1. Rely on Default Deployment Value:

    • Configure the script parameter's default value to 0 directly on the script deployment record.
    • When the scheduled script runs without an explicit parameter value being passed (e.g., if it's triggered by its schedule), the parameter will automatically start with its default value of 0.
    • If the script modifies this parameter during its execution, the change is only for that specific run and will not persist for subsequent scheduled executions.
  2. Implement In-Script Reset Logic:

    • Within the Scheduled Script itself, add logic to check for a specific condition at the beginning of its execution.
    • If a specific condition is met (e.g., if the parameter is not received or indicates a reset is needed), the script can directly set the parameter's effective value to 0 for that particular run. This allows for dynamic resetting based on internal script logic rather than relying solely on the deployment's default.

Expert NetSuite Support

Need help with this NetSuite issue?

SuiteScript Development consulting and configuration support

Talk to a consultant