---
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


---

# ServiceNow CPQ scripting language reference

# ServiceNow CPQ scripting language reference {#ariaid-title1}

Release version: Brazil  
Updated September 10, 2026  
![](https://www.servicenow.com/docs/portal-asset/ico-clock) 3 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 ServiceNow CPQ scripting language reference

ServiceNow CPQ uses a JavaScript-like scripting language to dynamically manipulate field values and bill of materials (BOM) data through rules and enrichments.
While it does not support the full breadth of JavaScript features due to complexity and performance considerations, it offers a robust and expanding set of operators, objects, and keywords tailored for product configuration within ServiceNow CPQ.
Show full answer Show less  

## Supported Features and Language Elements

* **Operators:** Includes arithmetic (+, -, , /, %, ++, --), string concatenation (+, +=), assignment (=, +=, -=), comparison (==, ===, !=, !==, \>, \<, \>=, \<=), and logical (\&\&, \|\|) operators.
* **Objects:** Supports arrays, strings, numbers, booleans, maps, and dates. Note that `undefined`, `NaN`, and `null` are unsupported, and date objects cannot be returned but can be manipulated.
* **Keywords:** Allows variable declarations (`var`, `let`, `const`), object creation with `new`, control flow with `if`, `else if`, `else`, `for`, and `for/of`, and `return`. It does not support `while` loops or functions to avoid infinite loops and complexity.

## Important Limitations and Alternatives

* No support for functions or `while` loops; scripts should be concise. For complex logic, consider using managed tables and table queries.
* Unsupported operators like exponentiation and compound assignments should be replaced with alternatives (e.g., use `Math.pow(x, y)` for exponentiation, and explicit multiplication or division assignments instead of `=` or `/=`).
* Type conversion methods are available (e.g., `Array.toString()`, adding an empty string to convert numbers to strings, subtracting zero to convert strings to numbers).
* Type checking is supported via utility functions like `LGK.isNumber()`.

## Accessing Object Properties and Practical Use Cases

Properties of map objects (e.g., `cfgRequest`) can be accessed using dot notation or bracket notation, enabling dynamic property references. This is particularly useful to replace repetitive code with table lookups, allowing scripts to adapt dynamically based on configuration data.

For example, a single script can set multiple fields based on a managed table lookup, efficiently handling conditional logic without duplicating code. This supports scalable and maintainable configuration scripts.

## Support and Further Assistance

If additional scripting capabilities are required beyond what is described, customers are encouraged to contact the ServiceNow CPQ team with their use cases for assistance.  
View the operators, objects, and keywords that ServiceNow CPQ supports, together with information about type conversion, type checking, alternative scripts for unsupported operations, and accessing object properties.
ServiceNow CPQ uses a JavaScript-like language to dynamically change the value of fields and BOM data via rules and enrichments. JavaScript is a complex language built over almost thirty years, and while we are unable to
replicate every piece of functionality that a developer would normally expect while coding, ServiceNow CPQ scripting remains a powerful tool to assist in the dynamic configuration of products.

The capabilities of ServiceNow CPQ scripting are always expanding. Check back to see the most up-to-date features.

## Supported operators {#cpq-logik-io-scripting-language-reference__suported_operators}

Arithmetic operators:

+
:   Addition

-
:   Subtraction

\*
:   Multiplication

/
:   Division

%
:   Modulus

++
:   Increment

--
:   Decrement

String operators:

+
:   Concatenation

+=
:   Addition assignment

Assignment operators:

=
:   Assignment

+=
:   Addition assignment

-=
:   Subtraction assignment

Comparison operators:

==
:   Equal to

===
:   Equal value and equal type

!=
:   Not equal to

!==
:   Not equal value nor equal type

\>
:   Greater than

\<
:   Less than

\>=
:   Greater than or equal to

\<=
:   Less than or equal to

Logical operators:

\&\&
:   And

\|\|
:   Or

## Supported objects {#cpq-logik-io-scripting-language-reference__supported_objects}

Each object supported can be declared with the following:

\[ \]
:   Array

" "
:   String

( )
:   Number

true \| false
:   Boolean

{ }, new Map( )
:   Map

new Date( )
:   Date

`undefined`, `NaN`, and `null` are unsupported.  
Note:  
Date objects cannot be returned, but they can be referenced and manipulated with the Date APIs in the Help menu.

## Supported keywords {#cpq-logik-io-scripting-language-reference__supported_keywords}

* `var`
* `let`
* `const`
* `new`
* `if`
* `else if`
* `else`
* `for`
* `for/of`
* `return`

{#cpq-logik-io-scripting-language-reference__ul_j4r_z42_dhc}

We do not support `while` or unconditional `for` loops with `break`, because of the risk of infinite loops halting performance.

We do not support functions, as the script itself should be small enough to be considered one function. If your script is long with many conditions and variables, consider creating a managed table and using a table query. For more
information about using managed tables and table queries, see [Matrix Loader: CSV table upload](https://servicenow-prod.fluidtopics.net/gU4BC27cEhvb5g7~y1Sutw "Use the Matrix Loader to import and manage table data in ServiceNow CPQ. Define table schemas, prepare matching CSV files, and upload them to populate or update tables for use in rules, lookups, and configurations, with no redeployment required for data updates.") and [Minimizing table queries](https://servicenow-prod.fluidtopics.net/o_AqQtEa8j9eDeZabycrTA "Learn how to minimize queries to maximize performance.").

## Alternative scripts for unsupported operations {#cpq-logik-io-scripting-language-reference__alternative_scripts_for_unsupported_operations}

Assignment multiplication and division (/= or \*=): `number = number * otherNumber;`, `number = number / otherNumber;`

Exponentiation (x\*\*y): `Math.pow(x, y);`

## Type conversion {#cpq-logik-io-scripting-language-reference__type_conversion}

Convert arrays to strings: `Array.toString()`

Convert numbers to strings: `[number] + ""`

Convert numeric strings to numbers: `[string] - 0`  
Note:  
Strings cannot be treated as arrays, but `.length` does work for strings.

## Type checking {#cpq-logik-io-scripting-language-reference__type_checking}

The following returns a Boolean value indicating whether an input is a number: `LGK.isNumber(123)`

## Accessing object properties {#cpq-logik-io-scripting-language-reference__accessing_object_properties}

You can access the properties of map objects such as `cfgRequest` in two ways.

    objectName.propertyName
    //or
    objectName["propertyName"]

This is helpful in order to replace large amounts of repetitive code with results from a Table Lookup, since the "propertyName" text could instead be replaced by a variable.

For example,
consider a blueprint with the following fields associated with it, and a managed table named shipstatebooleantest.

* shipState
* boolean1
* boolean2
* boolean3
* quantity1
* quantity2
* quantity3

{#cpq-logik-io-scripting-language-reference__ul_i5d_fq2_dhc}

|-|-|-|-|-|
| id | shipState | trueBoolean | quantityTest | rowQuantity |
| 1 | Arizona | boolean1 | quantity1 | 1 |
| 2 | Maine | boolean2 | quantity2 | 2 |
| 3 | California | boolean3 | quantity3 | 3 |
[Table 1. shipstatebooleantest]

{#cpq-logik-io-scripting-language-reference__table_l5q_jr2_dhc}

Instead of having an identical `if` statement check what `shipState` is and setting the Boolean values and quantities accordingly, you could instead replace it with only one `if`
statement that sets the values based on the results of a table lookup.

In the following On Configure/Reconfigure script, if the `shipState` field has a value, the fields that are returned by the lookup function
are set. If the `shipState` field is blank, then all Boolean and quantity fields are set.

    if (cfgRequest.shipState.value != "" && cfgRequest.shipState.value != null){
    	var fieldMapping = lookup("Select trueBoolean,quantityTest,rowQuantity from shipstatebooleantest where shipState = :value", { "value": cfgRequest.shipState.value });
    	console.log(fieldMapping);
    	if (fieldMapping != []){
    		cfgRequest[fieldMapping[0].trueBoolean].set("value",true);
    		cfgRequest[fieldMapping[0].quantityTest].set("value",fieldMapping[0].rowQuantity);
    	}
    }
    else{
    	var fieldMapping = lookup("Select trueBoolean,quantityTest,rowQuantity from shipstatebooleantest");
      console.log(fieldMapping);
      for (var row of fieldMapping) {
     		cfgRequest[row.trueBoolean].set("value",true);
     		cfgRequest[row.quantityTest].set("value",row.rowQuantity);
      }
    } 

If your instance of ServiceNow CPQ needs functionality not described here, contact support@logik.io with your use case.
**Related concepts**   

* [Using comments and the console to debug scripts](https://servicenow-prod.fluidtopics.net/RjpJ~wn3hCzbrCnMgh2ALw "Learn how comments and the console can help you debug your scripts.")
* [Scripting: Checking for first and subsequent configurations](https://servicenow-prod.fluidtopics.net/6nyBepNeoV9AzYuaCndqiA "You can test whether a configuration is being initialized or being reconfigured, and set code to execute based on the result.")  
**Related reference**   

* [Sample scripts](https://servicenow-prod.fluidtopics.net/F3TyjcyShLWckBjKPQwANw "View a selection of commonly requested sample scripts.")

