---
sourceDocument: Brazil Sales Customer Relationship Management
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/order-management

 Release :

    - brazil

ft:locale :

    - en-US

ft:publication_title :

    - Brazil Sales Customer Relationship Management

ft:clusterId :

    - omgmt

bundleId :

    - omgmt

workflow :

    - Customer and Industry


---

# Scripts

# Scripts {#ariaid-title1}

Release version: Brazil  
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

Scripting in ServiceNow CPQ extends configuration capabilities beyond simple declarative rules by enabling advanced logic for calculating values, evaluating conditions, and manipulating product data dynamically.
Scripts are used selectively to handle specialized scenarios where standard rules, picklist extensions, and product pickers are insufficient.
They enhance flexibility while maintaining safe and efficient configuration management.
Show full answer Show less  

## Where to Use Scripts

* **Rule Conditions:** Scripts return **true** or **false** to control whether related actions execute.
* **Rule Actions:** Scripts can set field values, control UI element visibility, or dynamically build product lists.
* **Blueprint Enrichments:** Scripts initialize data, validate configurations, enrich pricing, or interact with external systems during configuration events.

## Expected Return Values and Configuration Objects

Each script type requires specific return formats for predictable functionality:

* **Advanced Condition:** Boolean (`true` or `false`)
* **Advanced Hiding:** String identifying field to hide
* **Field Determination:** Depends on field type (Number, Text, Multi-select array)
* **Inclusion/Exclusion:** Array of values
* **Product Action:** ProductList object for managing BOM items
* **Enrichment:** Updated configuration object (`cfgRequest`)

Key configuration objects used in scripting include:

* `cfg`: Read-only snapshot of current field values
* `cfgRequest`: Writable configuration object for enrichment scripts
* `ProductList`: Manages bill of materials item additions or modifications

## Integrating External Data

Scripting supports dynamic enhancement of configurations through external data sources:

* **Managed Tables:** Use `lookup()` to query and map data into fields or product selections.
* **External Connections:** Approved external calls (e.g., Salesforce SOQL) can populate sets or field values within enrichment scripts.

This approach centralizes data management and reduces maintenance of hard-coded logic.

## Debugging and Best Practices

The scripting environment provides tools to simplify development and troubleshooting:

* Autocomplete suggestions for functions, variables, and fields
* Help panel with supported functions and usage examples
* Debugger supporting JSON input and displaying outputs and console logs
* Ability to save common test inputs as in-code comments for reuse

Best practices for scripting include:

* Favor declarative rules whenever possible
* Keep scripts focused, concise, and single-purpose
* Always return the correct expected data type
* Use clear variable names and thorough comments
* Avoid complex nested logic; leverage tables or external services instead  
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://servicenow-prod.fluidtopics.net/7zGvVmfUuA9sl4Rj8mWlkA "Learn how to create advanced functions using the scripting interface.")

