{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":37458,"path":"order-management/enrichments_on_configurer_and_reconfigure_behavior.md","title":null,"bundle":null,"doc_type":null,"release":null,"body":"---\ntitle: Scripting: Checking for first and subsequent configurations\ndescription: You can test whether a configuration is being initialized or being reconfigured, and set code to execute based on the result.\nlocale: en-US\ncanonical_url: https://www.servicenow.com/docs/r/australia/order-management/enrichments\\_on\\_configurer\\_and\\_reconfigure\\_behavior.html\nrelease: australia\ntopic_type: concept\nlast_updated: \"2026-03-12\"\nreading_time_minutes: 4\nbreadcrumb: [Setting up enrichments and rules scripting, CPQ Configurator, Configure, price, quote apps, Configure, Sales Customer Relationship Management]\n---\n\n# Scripting: Checking for first and subsequent configurations\n\nYou can test whether a configuration is being initialized or being reconfigured, and set code to execute based on the result.\n\nSometimes 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.\n\nThe methods below can be combined without interfering with one another and can lead to flexible and unique code behaviors for your configurable products.\n\n## userEdited: running only when a field was not edited\n\nTwo 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.\n\nThis can be used in if statements to write a default value only when the field has not been changed by the user. For example:\n\n```\nif (cfgRequest.[fieldVariableName].userEdited == false) {\n      //code to run\n}\n```\n\nAll 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.\n\n## The lineId partner field\n\nAlternatively, 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.\n\nThis is because when a CPQ configuration is initialized, this ID does not yet exist, because the configuration has yet to be saved. Only after a 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.\n\nScript 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.\n\nHere is how the field can be referenced in the On Configure/Reconfigure enrichment:\n\n```\ncfgRequest.partner.quote.lineId.value;\n```\n\nIf the behavior should only happen when the configuration is initialized, you could add the following check:\n\n```\nif (cfgRequest.partner.quote.lineId.value == null) {\n      //code to run\n      return cfgRequest;\n}\n```\n\nAdding the `return cfgRequest;` line in the check guarantees that any code after the check for the line ID will not be executed.\n\nSimilarly, if the behavior should happen only when the configuration is reconfigured, add the inverse check:\n\n```\nif (cfgRequest.partner.quote.lineId.value != null) {      \n      //code to run\n      return cfgRequest;\n}\n```\n\nFor more information on partner fields, see [CPQ fields, system fields, and partner fields](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/order-management/system_fields_vs_partner_fields.md).\n\n## isInitial: creating a text field\n\nAnother 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.\n\nCreate 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:\n\n```\nif (cfgRequest.isInitial.value === \"Yes\" || cfgRequest.isInitial.value === \"No\") {\n      cfgRequest.isInitial.set(\"value\",\"No\");\n}\nelse\n{\nc fgRequest.isInitial.set(\"value\",\"Yes\");\n}\n```\n\nOn initialization, the `isInitial` field will be blank. Therefore, the script will set the value of `isInitial` to Yes in the `else` clause.\n\nOn the first reconfiguration, `isInitial` will be Yes. Therefore, the script will set the value of `isInitial` to No in the `if` clause.\n\nOn every subsequent reconfiguration, `isInitial` will be No, and will remain No.\n\nThis 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.\n\nThis 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.\n\n"}}