Macros
Reminders:
- Macro allows to implement business rules using CPQ Macro language capabilities
- Macro can be used to compute any field in the quote header, any column and total cell in the quote spreadsheet.
- On column/total cell computation rules: macro cannot be used to update (via the API) the quote spreadsheet data
- Macro can be used to control the status lists in the approval process
- Macro can be used to define the domain of values of any field in the quote header, any column and total cell in the quote spreadsheet\
- Macro can be used to propagate the update of the column to its parent (Up propagation) as well as its children (down propagation)
- Macro can be used to automate specific actions triggered by events raised from the quote header or the quote spreadsheetinformation: The association with the macro is made through its name and therefore each macro must have a unique name within the quote model.
The content of the macro is written in the Macro Editor of Quote Designer.
Additional parameter can be declared in order to set global variable initialized with the result of the XPath request executed from the XML flow associated with the quote lines of type configured product (CP7) or standard product (CT7) or sales product (SP7)
Syntax:
variableName: <Xpath request>For more information about XPath request, refer to chapter XPATH request
Reference: : For more information about the syntax of the macro language, refer to CPQ Macro Language – Reference Manual
The table below details the specific syntax used to retrieve quote information and to send results from the macro:
| HOW TO...? | SPECIFIC SYNTAX AND EXAMPLE |
|---|---|
| Get contextual settings: | |
| Current language | aliasLang Example ‘FR”, “US” |
| Current line id | aliasLine Column/total cell computation only |
| Current field name | aliasField Header field computation only |
| Current column name | aliasColumn Column/total cell computation only |
| Quote line structure | rows["NR"] = <nblines> rows[1..N] = <lineId> rowTypes[<lineId>] = <lineType> parents[<lineId>] = <parentLineId> children[<lineId>] = "childLineId1, childLineId2… " Column/total cell computation only parentLineID=0 in case of the line has no parent children array gives for each lineId the list of the child lineId separated by a comma |
| New value | newEntry New user input value – macro before/after update field/column/total cell only |
| Set contextual information: | |
| Access to quote information: Header tab field (except address) | <tabName>.fieldName> <tabName>=ParameterTab; CartInfoTab; OrderInfoTab; ChangeAndControlTab |
| Access to quote information: Address tab field | AddressTab,<addressName>.<fieldname> <addressName>=SoldTo; BillTo; ShipTo |
| Access to quote information: Spreadsheet column | <colName>[aliasLine] colName are the ones defined in the spreadsheet grid |
| Access to quote information: Spreadsheet total cell For more information, refer to chapters Setting-up the Quote Header and Setting-up the Quote Spreadsheet | <totalCellName> totCellName are the ones defined in the spreadsheet totals |
| Update quote information | Using Quote business APIs Example: /* Step 1: Init a variable with the quote controller */ LET cartData Controller.getCurrentCartData() /* Step 2: Init a variable pointing to the business object to be updated for example: */LET curOwnerInfo cartData.getOwnerUser() /* Step 3: Execute the update using the appropriate method with the required parameters for example: */ curOwnerInfo.setUserID(newOwnerId) |
| Return a computation result Using DISPLAY keyword | Example: DISPLAY "result" /* returns a string value */ DISPLAY MyResult /* returns the value stored in MyResult */ |
| Return the domain of a given field/column/total cell Using pre-defined APListVal array | Example: LET APListVal["NR"] 2 /* number of records */ LET APListVal["DL"] 0 /* first line number */ LET APListVal["DC"] 0 /* first column number */ LET APListVal[0,0] "value1" /* col 0 contains the identifiers */ LET APListVal[1,0] "value2" LET APListVal[2,0] "value3" LET APListVal[0,1] "MY Value 1" /* col 1 contains the descriptions */ LET APListVal[1.1] "MY Value 2" LET APListVal[2.1] "MY Value 3" |
| Return an error message: Using ERROR keyword | ERROR 2 "my error message" /* channel 2 is used by convention */ |
| Return an information message: Using MESSAGE keyword | MESSAGE "my information message" |
