---
sourceDocument: Australia Sales Customer Relationship Management
sourceDocumentLink: https://www.servicenow.com/docs/r/australia/order-management

 Release :

    - australia

ft:locale :

    - en-US

ft:publication_title :

    - Australia Sales Customer Relationship Management

ft:clusterId :

    - omgmt

bundleId :

    - omgmt

workflow :

    - Customer and Industry


---

# Scripts

# Scripts {#ariaid-title1}

Release version: Australia  
Updated March 12, 2026  
![](https://www.servicenow.com/docs/portal-asset/ico-clock) 2 minutes to read
Summarize  
![AI sparkle icon](https://servicenow.com/docs/portal-asset/ai-sparkle-icon) Summarized using AI  
This content was generated using new OpenAI-powered functionality. Results are provided on an as is basis and are not guaranteed to be accurate or complete.  

## Summary of Scripts in ServiceNow CPQ Australia Release

Scripting in ServiceNow CPQ extends configuration capabilities beyond simple rules by enabling administrators to implement advanced logic for calculating values, evaluating conditions, and manipulating product data dynamically.
Scripts are incorporated within rule conditions, rule actions, and blueprint enrichments to support initialization, validation, and pricing during configuration events.
Show full answer Show less  
While scripting provides flexibility for specialized scenarios, it is intended to complement, not replace, declarative configuration options such as standard rules and picklist extensions. Customers are advised to use declarative methods first and reserve scripting for advanced needs.

## Where Scripts Run and Their Return Values

* **Rule Conditions:** Return a Boolean (true or false) to determine if actions execute.
* **Rule Actions:** Set field values, control visibility, or dynamically build product lists.
* **Blueprint Enrichments:** Run during "On Configure" or "Reconfigure" events to initialize data, enrich configurations, or call external systems.

Each script type requires a specific return format to ensure predictable behavior, such as Boolean values for conditions, strings for hiding fields, arrays for inclusion/exclusion lists, and ProductList objects for product actions.

## Key Objects and Data Interaction

* **cfg:** Read-only snapshot of current configuration field values accessible in rules.
* **cfgRequest:** Writable configuration object used in blueprint enrichments to modify field values dynamically.
* **ProductList:** Object used to add or modify bill of materials (BOM) items programmatically.

Properties on these objects can be accessed using dot or bracket notation (e.g., cfgRequest.fieldName or cfgRequest\["fieldName"\]).

## Using External Data

Scripts can enhance configurations by leveraging external data sources:

* **Managed tables:** Use the `lookup()` function to query and map data into fields or product selections.
* **External connections:** Approved external calls (such as Salesforce SOQL queries) can populate sets or fields during enrichment scripts.

This approach helps reduce hard-coded logic and centralizes data management for more maintainable configurations.

## Debugging and Best Practices

* Use the built-in scripting interface features including code autocomplete, help panels with function references, and a debugger that accepts JSON inputs and shows outputs and console logs.
* Save common test inputs as comments to facilitate repeated testing.
* Follow general guidelines: prefer declarative rules, keep scripts concise and focused, ensure correct return types, use clear variable names and comments, and avoid complex nested logic by utilizing tables or external data instead.

## Practical Benefits for ServiceNow Customers

By leveraging scripting within CPQ, customers can model complex configuration scenarios that exceed the capabilities of standard declarative rules. This enables dynamic pricing, customized product selections, and integration with external data sources, enhancing configurator flexibility and accuracy. The structured scripting environment and debugging tools help maintain reliable and maintainable custom logic.  
Learn how scripting extends ServiceNow CPQ beyond simple rules---understand where scripts run, what they return, and how to use them to model advanced configuration logic safely and efficiently.
Scripting enhances ServiceNow CPQ when configuration logic requires more flexibility than simple rules. Administrators can use scripts to calculate complex values, evaluate conditions, or manipulate product data dynamically. Scripts are available
in rule conditions, actions, and in blueprint enrichments for initialization, validation, or pricing.

Scripting complements, but does not replace, declarative options. Use standard rules, picklist extensions, and product pickers first. Reserve scripting for specialized scenarios.

## Where can you use scripts {#scripts__section_rsk_1sy_ghc}

* Rule conditions: Return `true` or `false` to determine whether actions run.
* Rule actions: Set field values, hide or display elements, or build product lists dynamically.
* Blueprint enrichments: Initialize data, call external systems, or enrich configurations during "On Configure" or "Reconfigure" events.
{#scripts__ul_uhs_bsy_ghc}

Each script type requires a specific return value to ensure predictable results.

## Expected return values {#scripts__section_t4f_dsy_ghc}

{#scripts__table_iry_dsy_ghc__entry__3}

| Script Type | Return Format | Example |
|-|-|-|
| Advanced condition | Boolean | `true` or `false` |
| Advanced hiding | String | `"field_to_hide"` |
| Field determination | Depends on field type | Number → `5`; Text → `"Red"`; Multi-select → ["Option1", "Option2"] |
| Inclusion and exclusion | Array | `["OptionA", "OptionB"]` |
| Product action | ProductList object | `ProductList.add({id:"123", qty:2})` |
| Enrichment | Updated configuration object | `return cfgRequest;` |
[Table 1. Expected return values]

{#scripts__table_iry_dsy_ghc}

## Configuration objects {#scripts__section_llw_3sy_ghc}

Scripts interact with the following configuration objects:

* `cfg`: A read-only snapshot of current field values used by rules.
* `cfgRequest`: A writable object available in Enrichments; use `.set("value", x)` to modify fields.
* `ProductList`: Used to add or modify items in the bill of materials (BOM).

{#scripts__ul_uvx_jsy_ghc}

You can reference properties using either dot or bracket notation (`cfgRequest.fieldName` or `cfgRequest["fieldName"]`).

## Working with external data {#scripts__section_vxc_lsy_ghc}

Use external data to enhance configurations dynamically:

* Managed tables: Query data with `lookup()` to map results into fields or products.
* External connections: Make approved calls (for example, SOQL queries to Salesforce) to populate sets or field values in Enrichments.

{#scripts__ul_udg_msy_ghc}

These techniques reduce hard-coded logic and centralize data management.

## Debugging and testing {#scripts__section_qzg_nsy_ghc}

The scripting interface includes built-in tools:

* Code suggestions: Autocomplete for functions, variables, and fields.
* Help panel: Lists all supported functions and parameters with examples.
* Debugger: Accepts JSON input and displays output and `console.log()` results. Save common test inputs as comments for reuse.
{#scripts__ul_kb5_4sy_ghc}

## General guidelines {#scripts__section_dtx_rsy_ghc}

* Prefer declarative rules when possible.
* Keep scripts concise and focused on a single task.
* Always return the expected data type.
* Use clear variable names and comments.
* Avoid nested or long conditional logic---use tables or external connections instead.
{#scripts__ul_egh_ssy_ghc}
**Related concepts**   

* [Create scripts](https://www.servicenow.com/docs/lLLO7eBPztvD88bl_rY0AQ "Learn how to create advanced functions using the scripting interface.")

