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


---

# Scripting: Checking for first and subsequent configurations

# Scripting: Checking for first and subsequent configurations {#ariaid-title1}

Release version: Brazil  
Updated March 12, 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 Scripting: Checking for first and subsequent configurations

This guide explains how ServiceNow CPQ customers can distinguish between the initial configuration of a product and subsequent reconfigurations using scripting.
This distinction is important for executing specific code only during initialization or reconfiguration to enhance configurator behavior and user experience.
Show full answer Show less  

## Key Methods to Detect Configuration State

* **Using `userEdited` Property:** Each field in the configuration has a Boolean `userEdited` property indicating if a user has modified it. On initial configuration, all fields have `userEdited = false`. During reconfiguration, fields the user changed have `userEdited = true`. This enables conditional scripting to set default values only when fields haven't been edited by the user.
* **Checking the `lineId` Partner Field:** The `lineId` field contains the Salesforce quote line ID only during reconfiguration, not during initialization. Scripts can check if this field is null to determine the configuration state. This is useful when Salesforce integration is in place and allows a single check in the On Configure/Reconfigure enrichment script:
  * If `lineId` is null, code runs only on initialization.
  * If `lineId` is not null, code runs only on reconfiguration.
* **Creating a Custom `isInitial` Field:** This approach involves adding a text variable named `isInitial` to the blueprint and controlling its value via scripting:
  * On first initialization, `isInitial` is blank and set to "Yes".
  * On first reconfiguration, it changes from "Yes" to "No".
  * On subsequent reconfigurations, it remains "No".

  This method works independently of Salesforce and allows referencing `isInitial` in other rules or scripts to create behaviors specific to initialization or reconfiguration.

## Practical Benefits for ServiceNow CPQ Customers

* Allows setting default field values only on the first configuration, preserving user input on edits.
* Enables flexible scripting to create unique and context-aware configurator behaviors.
* Supports Salesforce integration by leveraging the `lineId` to determine configuration state.
* Provides a method that does not rely on Salesforce data by using a custom `isInitial` field.
* Helps maintain a consistent user experience by carefully controlling differences between initialization and reconfiguration logic.  
You can test whether a configuration is being initialized or being reconfigured, and set code to execute based on the result.

Sometimes it is necessary to execute code only when the configuration is being initialized, or only when it is being reconfigured. For example, you might want to set a field to its default values at the beginning of a
configuration, but keep the userʼs selection during any future edit.

The methods below can be combined without interfering with one another and can lead to flexible and unique code behaviors for your configurable products.

## userEdited: running only when a field was not edited {#enrichments_on_configurer_and_reconfigure_behavior__section_hbg_vrr_4hc}

Two field properties can be accessed in the On Configure/Reconfigure enrichment: value and userEdited. While the value property holds the data contained in
the field and is usually what will be accessed when scripting, userEdited contains a Boolean value that stores whether the field has been changed by the end user.

This can be used in if statements to write a default value only when the field has not been changed by the user. For example:

    if (cfgRequest.[fieldVariableName].userEdited == false) {
          //code to run
    }

All fields will have the userEdited property set to false when the configuration is initialized, but when reconfiguring, some will be set to true based on the changes made by the user. If youʼd like a behavior to occur
only when a field has or hasnʼt been edited, write the code to execute after one of these checks.

## The lineId partner field {#enrichments_on_configurer_and_reconfigure_behavior__section_gnt_wrr_4hc}

Alternatively, if youʼd like to make only one check in the On Configure/Reconfigure enrichment script, and have Salesforce integration, the lineId partner field will only be populated with the
Salesforce ID of the parent configurable productʼs quote line when reconfiguring. It will not be populated when a configuration is initialized.

This is because when a ServiceNow CPQ configuration is initialized, this ID does not yet exist, because the configuration has yet to be saved. Only after a ServiceNow CPQ configuration has been created and the quote line editor saved are any quote lines created in Salesforce. So, when we see that the lineId partner field is present, we
can be sure that the current session is due to a reconfiguration, not a new configuration.

Script writers can take advantage of this distinction by putting any code that must be run only on initialization or reconfiguration under a check for this value.

Here is how the field can be referenced in the On Configure/Reconfigure enrichment:

    cfgRequest.partner.quote.lineId.value;

If the behavior should only happen when the configuration is initialized, you could add the following check:

    if (cfgRequest.partner.quote.lineId.value == null) {
          //code to run
          return cfgRequest;
    }

Adding the `return cfgRequest;` line in the check guarantees that any code after the check for the line ID will not be executed.

Similarly, if the behavior should happen only when the configuration is reconfigured, add the inverse check:

    if (cfgRequest.partner.quote.lineId.value != null) {      
          //code to run
          return cfgRequest;
    }

For more information on partner fields, see [ServiceNow CPQ fields, system fields, and partner fields](https://servicenow-prod.fluidtopics.net/HVtsYoocfzNKUKZ5buQi6w "Learn about the three types of fields in ServiceNow CPQ—ServiceNow CPQ, system fields, and partner fields. Understand how each type stores, retrieves, and displays data in configurations, and how they interact with Salesforce and partner systems for seamless data integration.").

## isInitial: creating a text field {#enrichments_on_configurer_and_reconfigure_behavior__section_yq5_xrr_4hc}

Another way to guarantee that a distinction is present (regardless of whether Salesforce is used as an entry point into the configurator) is to create a field that checks whether the current configuration is due to an
initialization or a reconfiguration.

Create a text field with the variable name `isInitial`. Associate the field with your blueprint. Then, in the On Configure/Reconfigure enrichment, add the following lines:

    if (cfgRequest.isInitial.value === "Yes" || cfgRequest.isInitial.value === "No") {
          cfgRequest.isInitial.set("value","No");
    }
    else
    {
    c fgRequest.isInitial.set("value","Yes");
    }

On initialization, the `isInitial` field will be blank. Therefore, the script will set the value of `isInitial` to Yes in the `else` clause.

On the first reconfiguration, `isInitial` will be Yes. Therefore, the script will set the value of `isInitial` to No in the `if` clause.

On every subsequent reconfiguration, `isInitial` will be No, and will remain No.

This method has the added benefit of not having to save the entire QLE in SFDC in order to make the distinction between an initialization or reconfiguration. The method immediately detects when the
user enters the configurator a second time.

This method also includes the ability to reference the new field as a condition in rules, such as making a rule fire specifically on initialization or reconfiguration. It does not require the behavior to exist only in
the On Configure/Reconfigure script. However, to keep the configuring experience similar from the end user's perspective, you should be wary of making too many behavioral differences between initialization and
reconfiguration.

