A Submit Rule is executed when the user clicks "Add to Quote" on a configuration and finishes their work.
Doing so saves their configured product, adds that configured product to a quote, and closes the configured product UI screen. A Submit Rule is the opposite of a Loaded Rule (which runs once, when a configurator is first opened on the user's screen). Use the Submit Rule for logic that should be applied only at the moment the user submits their configuration.
Arguments
Arguments are variables passed in to the rule. You can find them by using the Get/Set variable snap blocks. In this rule type, the Get block exposes these arguments:
Name | Type | Description |
---|---|---|
clientLanguage | text | the two-character code representing the current user's preferred language. |
configurator | Configurator | the current running configurator. |
environment | string | "dev" if you are in the development environment, "test" if you are in the test environment, and "prod" if you are in the production environment. |
isEdit | boolean | true if the configurator that is being loaded is an edit of a pre-existing configured product inside a quote; false if it's a new, never-before-saved configurator accessed from the product page. |
isMobile | boolean | true, if the viewport seems to have the size of a mobile device. Use this flag to show something differently on screen if required by a smaller device. |
parameters | map | a map of GET or POST parameters passed into the configurator when it was launched. |
quoteProduct | QuoteProduct | |
user | User | the current user. |
Parent Quote object not guaranteed.
Your user can create a configuration in two ways: by having an existing quote and adding a new configuration to it, or by simply launching a configurator with no existing quote yet, and saving that configuration (the missing parent quote is created for them automatically after the configuration is submitted). Therefore, at the moment the Submit Rule runs, the configuration being submitted may or may not have a parent quote. Your rule should allow for both conditions: if you are gathering information from the quote to use in your Submit Rule, ensure that logic fails gracefully when there is no quote yet. Use the "isEdit" boolean to determine the current condition.
After the submit rule completes, other steps then begin (such as the creation of the parent quote, if none exists, and then any Quote Rules that should run on that parent quote).
Examples
You may want to update one field when the configured product is first submitted, and a second field every time it is submitted. This can help you track how long it takes for your workflow to process the configured product, and how many times a configurator is re-submitted.
You may want to ensure the quote has at least one item, and stamp a unique number onto the quote using a generator:
Another use case: you may have some calculations or database queries which may take some time, and aren't necessary for the user to wait for. These operations can be deferred to run only during the Submit Rule, which won't add any lag to the user experience. The delay will be seen by the user after they've submitted their product, not while they are configuring it.
Snap rules run in a specific order, and in response to specific events. Learn more about rule execution order.