In SAP CPQ scripts are managed in Setup under Develop > Global Scripts. A more detailed documentation for scripting is available on the dedicated Scripting page.

Details regarding all the scripts in the system are displayed in the following columns:

  • Name- The name of the script.
  • Execution Time -The execution event when the script is executed. The following available events trigger scripts at a precise time:
    1. Every time quote is changed - after each change on the quote that affects the Date Modified field.
    2. Quote creation/edit
      1. Quote creation - immediately after a quote is created.
      2. Quote edit - after the action Edit quote is executed.
    3. After adding products to quote
      1. After adding products to quote - each time an item is added. If several items are added at once (from catalog or through bulk validation), the scripts are executed after the last item (not after each item is added).
      2. After editing products in quote -after a user finishes editing a product in the quote.
      3. After copying products from quote - after a user copies a product in the quote.
      4. After deleting products from quote - after a user deletes an item in the quote. If several items are deleted at once, the scripts are executed after all items are deleted.
    4. After changing the value of custom fields - when a particular custom field is changed. For events that are triggered when a custom field is altered, you are able to select the custom field from the system.
    5. Custom fields calculation - after users choose the calculation type.
      1. Before custom field calculation - before the formula is calculated.
      2. After custom field calculation - after the formula is calculated.
    6. When a user is on quotation tab - when a user is on a particular tab in the quote. As soon as a user clicks on the particular tab, SAP CPQ executes the scripts specified for the tab. When the user clicks Save on this tab, the scripts specified for the tab are executed. The event is executed in the following tabs: Additional Info, Customer Info, Documents, Quotation and Quotation.
    7. When quote layout is rendered - when the customization related to the layout of the quote (modify XML and add additional data) that cannot be accomplished with simple changes to quote XSLT is performed. The event is deprecated in the new SAP CPQ layout.
    8. When catalog layout is rendered - when the customization related to the catalog of the quote (modify XML and add additional data) that cannot be accomplished with simple changes to quote XSLT is performed. The event is deprecated in the new SAP CPQ layout.
      1. On product xml serialization start - before the xml serialization starts.
      2. On product xml serialization end - when the xml serialization finishes.
    9. When product is ready - executed after a product is loaded and configured (if configurable), but before it is added to a quote.
    10. When product is loaded - executed after a product is loaded, configured (if configurable) and added to a quote.
    11. On Arrive From CRM - when users have arrived from SAP CPQ.
      1. On Customer Mappings - when creating and assigning customers to quotes.
      2. On Quote Fields Mappings - when retrieving different quote fields from CRM.
    12. On Landing From CRM - chronologically, happens before arriving from CRM and after the authentication handshake. This event has the request context.
    13. On CRM Item Mappings - when sending items from SAP CPQ to Salesforce. Applicable only when SAP CPQ is integrated with Salesforce.
    14. On Asset Created - after the action Create Assets is triggered.
    15. On user Login - when users log into SAP CPQ.
    16. On customer change - when the Bill To, Ship To and End User customers are changed.
    17. Document Sent To Customer - in the last step of the Document Generation process. Administrators can define a script that changes the status of the quote to Sent to Customer.
    18. On Quote Tab Changed - when moving to a quote tab (e.g. a script can be executed to create a quote table in the current tab).
    19. Before Quote Rendering - every time a user makes any change on a quote. For example, if the visibility of a custom field is set in a script, administrators can attach that script to this new event. That way, they make sure the field is always visible, regardless of the changes that users make on the quote.

When multiple scripts are attached to an event, it is possible to change their execution order by clicking the event > Execution order.

  • Code - holds code in Iron Python script language.
  • Description
  • Active - false and true.
  • Module - false and true.
  • Modified Date - the date when the script was last updated.
  • Modified By - the name of the user who last modified the script.

Create a Script

A script contains a series of commands that can be executed without being compiled. SAP CPQ provides a user-friendly interface for administrators to create and manage scripts.

  • In Setup, access Develop > Global Scripts.
  • Click Add New and a page with three tabs displays: Script (for creating and editing scripts), Events (for tying a script to an event) and History (for displaying all the versions of the script and the time and date of its creation/editing).
  • Define the Rule Name. Please note that the field is required.
  • (Optional) Describe the script in Description.
  • Select Active if you wish the script to be active in the system.
  • Select Module to use the code in other scripts. Please note that the scripts that have this option selected cannot be used independently, but only as a part of other scripts.
  • Define the start and end date of the script. These fields are disabled if Module is selected.
  • The Modified by and Modified on are disabled and the system automatically populates them once the script is saved.
  • In the Scripting Code section, choose the script engine type. SAP CPQ currently supports IronPython for creating scripts.
  • (Optional) Select Force Proxy Generation to load and refresh the WSDL web services as the system does not do it by default. The checkbox needs to be selected only once when the script is saved for the first time.
  • Write your script in the Script box.
  • Click Save.

Note: Using IronPython in SAP CPQ is limited as the system does not support standard IronPython modules. You cannot add external .NET and complex IronPython modules to SAP CPQ scripts. However, in basic user scenarios, you can paste the content of a simple module (without dependencies on other modules) into the SAP CPQ script module and the system will process it properly.

When an administrator is creating a new script and clicks on Attach to Event, SAP CPQ saves the new script. The administrator is not allowed to move to the Events tab unless the script name is properly defined. When creating a script, users can click Check Syntax to validate the script.
The screenshot below shows the interface when the script syntax is correct:

The following screenshots show the interface when a script contains errors:

The flag ITrace.IsOn, which is available in scripting, indicates whether tracing is turned on or off. With the help of this flag, users can organize the logic that is related to tracing and thus optimize script execution time.

Saving Quotes on Events

The table below shows which elements of quotes are automatically saved after some events are triggered. The data in the table is useful when creating scripts so you know when to include the Save action.

Events Custom Fields Line Items Product Types Totals Quote Tables
After adding products to quote Saved Saved Saved Saved
After editing products in quote Saved Saved Saved Saved
After deleting products from quote Saved
After copying products in quote Saved
After changing value of custom fields
Quote creation
Quote edit Saved
On user Login
On customer change
Document Sent To Customer
On Quote Tab Changed
When Excel is uploaded into a Quote Table

Exceptions for Quote.Save() Pipeline Execution

When certain parts of a quote are changed, calculations need to be performed and changes saved. As this does not require all events from the pipeline to be triggered, some of them can be skipped. This is determined by the Quote.Save() parameter. This parameter is by default set to True, which causes the entire pipeline to be executed whenever changes on quote are saved. If the Quote.Save() parameter is set to False, the following events will not be triggered:

  • Quote creation
  • Before custom field calculation
  • After custom field calculation
  • Every time quote is changed
  • When user is on quotation tab
Forbidden .NET Classes and Namespaces

The following .NET namespaces and classes are forbidden in IronPython scripts:

  • System.IO
  • System.Data
  • System.Configuration
  • Webcom.Configurator.Util.ConnectionStringProvider
  • System.Environment
  • System.GC

These namespaces and classes were available before the 1902 release, so administrators may had used them in client scripts. In such cases, errors will display after the 1902 release when administrators save those scripts.

If there are scripts that contain System import * and Webcom.Configurator.Util import * and any of the words from the forbidden classes, the system disables saving scripts (for example, saving is disabled if there is System import * and Data in the same script).

For troubleshooting, please contact the SAP CPQ Support team.

More Information

You are here: SAP Sales Cloud CPQ Online HelpAdmin Page HelpScripting