Script Parameters

Overview

Without parameters, scripts often include hardcoded values:

let token = "1234";
let isTest = true;
let templateId = "email_001";

This creates several issues:

  • Difficult to reuse the same script for different scenarios
  • Requires code changes for small updates
  • Increases risk when modifying production scripts

Script Parameters allow you to define dynamic values outside of your script and reuse them across deployments without modifying the code.

Configure Script Parameters

Watch the guided demo below to configure parameters.

You can also follow the same steps using the written guide below.

Step 1: Create a Parameter

  1. Go to Settings > System Settings.
  2. Select Workflows menu.
  3. Open the Scripts tab.
  4. Click + Add script to create a new script. You can also update an existing script.
  5. In the Create Script tab, fill in all the necessary information. Refer to the Workflows and Scripts page for more details.
  6. Go to the Parameters section and click the + button to create a new parameter. Configure the following:
    1. Name: Display name of the parameter
    2. Parameter ID: Unique identifier used in code.
    3. Description: Optional explanation of what the parameter is used for
    4. Type: Available types are Text, Number, Select, Multiselect, and Checkbox.
    5. Required: If enabled, the parameter must have a value in the deployment
📘

Info

  • If you choose Text as the type, you can mask the value (useful for tokens, secrets).
  • If you choose Select / Multiselect as the type, you must specify a record source (e.g., Employees, Customers).
  1. Save the script.

Step 2: Set Parameter Values in Deployments

After creating parameters, you must assign values in the deployment.

  1. Go to the Manage Deployments tab.
  2. Click + Add deployment to add a new deployment.
  3. Fill in all the necessary information, refer to the Deployments page for more details.
  4. In the Parameters section, enter values for each parameter you've set before.
  5. Save the deployment.

Step 3: Use Parameters in Scripts

  1. Go back to the Manage Script tab.
  2. You can access parameters in your script using:
C.parameter("parameter_name")

Example:

Using a Token Parameter

In this example, the token value is retrieved from the deployment, so no hardcoding is required.

async function script(C){
    let token = C.parameter("token");
    C.log(token);
}
Using a Checkbox Parameter

This allows you to toggle behavior without modifying the script.

async function script(C){
    let isTest = C.parameter("is_test");

    if (isTest) {
        C.log("Running in test mode");
        return;
    }

    C.log("Running in production mode");
}
📘

Note

Trying to access parameters that do not exist, or parameters that are required but not filled throws errors.

(Optional) Step 4: Add Workflow to a Record

If you set the script and deployment action is by Button was Pressed, then you need to add the workflow to the record.

  1. Go to the record > click the three-dot (⋯) menu > select Configure Record.
  2. In the side navigation, select Entry Layout, then choose the layout you want to update.
  3. Select the Header component.
  4. In the Inspect tab, click Open editor to modify the layout configuration.
  5. Add the workflow configuration below and include your Workflow ID:
"buttonsMenu": [
  {
    "type": "workflow",
    "key": "seyWqHGo-VoMJRk-FTOyf"
  }
]
  1. Save the layout.

Step 5: Run and Test

  1. Open the record.
  2. Trigger the workflow.
  3. Check the logs.
  4. You should see the parameter value being used.

📌 Need Help?

If you require assistance or encounter any issues, please don't hesitate to contact us for further support.