Create scripts

  • Release version: Australia
  • Updated March 12, 2026
  • 1 minute to read
  • Learn how to create advanced functions using the scripting interface.

    Some use cases require an advanced condition or action. Other times, the administrator may prefer script versus leveraging simple rules. For these occasions, CPQ offers the ability to write scripts in key areas.

    Scripting is available in rule actions and conditions, behind the Advanced menu choice or toggle.

    Rule

    When you click Create Advanced Function, the script editor opens, including the tools you need to write a script.

    When the script editor first opens, it provides the expected return format of the script.

    • Advanced conditions return true or false.
    • Advanced hiding rules return a text string.
    • Advanced determination rules return the type of the field that they are setting.
      • A determination rule that sets a number returns a number.
      • A determination rule that sets a multi-select picklist returns an array.
    • Advanced inclusion and exclusion rules return an array.
    • Product rules return ProductList.

    For more details and a script sample, review the "Advanced product actions" section of Rules.

    The ? Help button opens a menu of available functions. Each entry includes a description of the function, the parameters it accepts, its output, and an example that can be inserted at the current location of the cursor in the script.

    Script

    As you type in the script editor, suggestions are provided, including functions, configurable field variable names, and local variables. Using this feature helps eliminate mismatched variable names and typing errors. In the screenshot below, typing Ma gives the user two available functions (Map and Math) and a list of all matching fields. Additional inputs narrow the list of matching options.

    Map structure

    At the bottom of the scripting interface, the debugger lets you test your script by defining values for the variables (fields) that it references. Debugger input is provided in JSON format. For your convenience, review field-specific formats in the fields information help (arrow).

    Help screen

    It can be helpful to save your debugger inputs as comments in your script for easy pasting into the debugger when you need to test the script.

    Calls to console.log() in the script are returned in the debugger output.