--- title: "Create ERP Sales Order" slug: "create-erp-sales-order" description: "Learn how to run a Groovy scrip to enable a custom implementation when an ERP sales order is created." updated: 2026-06-02T14:10:36Z published: 2026-06-02T14:10:36Z canonical: "docs.zilliant.com/create-erp-sales-order" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.zilliant.com/llms.txt > Use this file to discover all available pages before exploring further. # Create ERP Sales Order ## Purpose Allows you to run a script to enable a custom implementation when an ERP sales order is created. ## Create ERP sales orders from CPQ ### Setup 1. Upload the script for **Create ERP Sales Order**. For details about uploading and configuring Groovy scripts, read [Upload a Groovy script](/v1/docs/upload-a-groovy-script). 2. [Enable the script.](/main/docs/create-erp-sales-order#enable-the-script) #### Enable the script You must enable this script in system settings. Follow these steps: 1. In CPQ, from the left navigation area, select **Administration**. 2. From the top navigation bar, select **Master Data Management**. 3. Select **SettingBoolean**. 4. Search for **Setting Custom Implementation for Sales Document Creation in ERP**. 5. Set the **Setting Value Boolean** switch to **YES**. ### Binding variables In addition to the [common binding variables](/v1/docs/binding-variables), the following binding variables are available for this extension point. | Variable name | Class | Description | | --- | --- | --- | | quoteBO | BusinessObject | Quote business object | | salesOrderDTO | JSONBusinessObjectDTO | Data about the sales order | For details about the classes listed in this table, including available methods, fields, and method signatures, read the [Zilliant Groovy API reference](/main/docs/groovy-api-reference). ### Expected output The ERP ID of the generated sales order, as a string. ### Script execution If the setting is enabled, the script runs automatically when a user creates an ERP sales order on the ERP Helpers screen. ## Create ERP sales orders from Commerce You can use a Groovy script to define the sales order type when a Commerce order is placed in the ERP. This gives you the flexibility to conditionally set the sales order type during order creation. ### Sample script ```groovy import com.imc.iss.groovy.GroovyLogger; import com.imc.iss.groovy.GroovyCtxUtil; import com.imc.vocabulary.Schema; String orderType = ""; def userBO = userInfo.getUserBO(); def personBO = groovyCtxUtil.getRelAttr(userBO, Schema.containsPerson); groovyCtxUtil.loadBO(personBO); def accountBO = groovyCtxUtil.getRelAttr(personBO, Schema.contactContainedBy); def salesInfoBO = groovyCtxUtil.getRelAttr(accountBO, Schema.definesSalesInfo); def salesOrg = groovyCtxUtil.getRelAttr(salesInfoBO, Schema.hasSalesOrg); def salesOrgERPId = groovyCtxUtil.getObjectERPId(salesOrg); // TODO: set the order type 'orderType' based on the sales area information return orderType; ``` ## Setting a default sales document type during order creation Setting a default sales document type: - **Enhances the efficiency of order creation**. Including the "Defaulting Sales Document Type During Order Creation" feature helps make the order creation process more efficient. By enabling authorized users to specify a default sales document type through master data, you eliminate manual tasks and reduce the incidence of errors. - **Streamlines the user experience**. When users initiate the order creation or order copying process, the system automates the assignment of the default sales document type. This reduces the need for manual selections and ensures consistency in order categorization.