- 08 Nov 2024
- 1 Minute to read
- Print
- DarkLight
Quote to Sales Order Creation
- Updated on 08 Nov 2024
- 1 Minute to read
- Print
- DarkLight
Purpose
Allows you to run a script when users create an ERP sales order, to set default values for specified fields on the New Order screen. In the script, define custom logic for setting default field values, leveraging data from various lookup tables.
By using this extension point, you can tailor the sales office assignment and other relevant attributes in the Sales Order object to meet your unique business requirements.
Setup
Upload the script for Quote to Sales Order Creation.
For details about uploading and configuring Groovy scripts, read Upload a Groovy script.
Binding variables
In addition to the common binding variables, the following binding variables are available for this extension point.
Variable name | Class | Description |
---|---|---|
order | Order | Represents the order. |
salesItemsTree | SalesItemsTree | Represents the quote. Contains functions you can use to query and modify the quote and its line items. |
userInfo | UserInfo | Represents all users in the system. |
Sample script
Use the following sample Groovy script to upload for this extension point:
import com.imc.iss.groovy.salesitem.SalesItemsTree;
import com.imc.iss.groovy.GroovyCtxUtil
import com.imc.iss.groovy.GroovyLogger
import com.imc.iss.groovy.order.Order
import com.imc.iss.groovy.order.OrderItem
import com.imc.vocabulary.Schema
/*
*
*
*
* Binding
* groovyLogger : GroovyLogger
* groovyCtxUtil : GroovyCtxUtil
* order : Order
* salesItemsTree
* userInfoList
* lookuptable/view and other default binding
*/
def creatorName = userInfo.getUsername();
groovyLogger.notifyInfo("creatorName = "+ creatorName)
groovyLogger.notifyInfo("Quote ID : "+ salesItemsTree.getQuoteURI());
//groovyLogger.notifyError("Quote ID : "+ salesItemsTree.getQuoteURI());
//Logic to get relevant OrgUnits to set default Sales Office and Sales Organization values
//MX Office Equipment
def salesOrg = "https://<base_url>/OrgUnit#ffaaf902baea429f92451aba6384f407";
//MX Office Equipment DE
def salesOffice = "https://<base_url>/OrgUnit#f7aefaad605d4800a81ace7d381e5883";
groovyLogger.notifyInfo("salesOrg : "+ salesOrg);
groovyLogger.notifyInfo("salesOffice : "+ salesOffice);
order.setRelationAttribute(Schema.hasSalesOffice.getUriAsString(), salesOffice);
order.setRelationAttribute(Schema.hasSalesOrg.getUriAsString(), salesOrg);
Expected output
No output expected.
Script execution
A script that you upload for this extension point is run automatically when a user creates a sales order from a submitted quote.
Create a sales order
- Open a quote.
- From the bottom button bar, select ERP Helpers > Order.
- From the bottom button bar, select Generate Sales Orders.
Zilliant CPQ executes the uploaded Groovy script. On the New Order screen, on the Overview tab, default values of specific fields follow the logic defined in the script.