You are here: Commerce Process > Commerce Rules

Commerce Rules

OVERVIEW

CPQ Cloud provides the ability to create commerce rules that are similar to the configuration rules. Commerce rules allow you to do things like limit the values in one field based on the selections in another and hide attributes based on other selections. They can be created at the main-document and sub-document levels. Rules that are created on the main-document or sub-document levels can affect attributes on either level. Example: you can write a constraint rule where the condition attribute is on the main-document and the action attribute is on the sub-document. Users have the ability to create, edit and view all commerce rules from a central location.

ClosedAvailable Commerce Rules


ClosedCommerce Rule Editor

Commerce rules are all created, edited and viewed from a central location, similar to the Data Table repository. This allows you to create all of your rules in one place.


ClosedMain-Document Rules

Rules created at the main-document level can affect both main-document and sub-document attributes. When a rule is created at this level but run on a sub-document attribute within the line item grid, the rule action will be performed on the entire column within the line item grid.Example: if you would like to hide "Discount" for a particular part number. If the rule condition is met anywhere in the line item grid, the entire column will be hidden for all line items.


ClosedSub-Document Rules

Rules created at the sub-document level can only affect sub-document attributes. This functionality allows for rules to evaluate each line within the line item grid individually. Example: if you wanted to hide "Discount" for a particular part number, the rule would evaluate each line item and if the condition is met, only that line item is affected. In this case, the input field for Discount would be removed for that particular line item.


ClosedRule Behavior

Similar to configuration rules, a commerce rule will fire when the condition evaluates to true. The condition of an AJAX enabled commerce rule is re-evaluated when any of its input attributes is changed either by the user or by the auto update function. Input attributes include condition and action attributes and any attributes used as inputs to the condition or action advanced function. Commerce rules also function when the user interacts with CPQ Cloud via SOAP. They even fire when the condition or action attributes are not mapped to the layout, or may not be visible.

New Validation rules are evaluated and executed after the action is performed. New Validation rules associated with Update Line Item fire when the action is called implicitly or when another modify-type action is performed. Simple validations, like required, range check, and so on, will fire automatically for attributes that are associated with hiding or constraint rules. For attributes not associated with rules, these validations fire when an action is performed. For SOAP, rule information is embedded in GetTransaction and CreateTransaction responses and validation message in UpdateTransaction response. Advanced validations are being deprecated for new implementations. Use standard validations instead.


Commerce Rule Elements: A commerce rule is comprised of a condition and an action. The condition is always evaluated first. If the condition is evaluated to be true (is met), then the rule is fired (action will be performed). Each of the rules start with a basic template of three sections:

This section is where you will enter the basic details about the rule (for example, the name, status and where it will be applied).


The condition section allows you to select the logic that specifies when the rule should run.


The action section is where you select WHAT happens if the condition is met. All rule types can be written using the simple action editor.


ADMINISTRATION

ClosedHiding Rules

Similar to hiding rules in configuration, hiding rules in commerce are created to hide attributes from the buyer when certain conditions are met. Commerce hiding rules are run using AJAX, meaning that an action doesn’t need to be performed in order for them to run. A hiding rule has a condition and an action. When the condition is met, the rule will hide the action attribute(s). Hiding rules can be written and/or run on attributes in the main-document or sub-document. Different from constraints, hiding rules written on the sub-document level can only hide sub-document attributes.

ClosedAdding a Hiding Rule

ClosedHiding Rules on Sub-Document Level


ClosedConstraint Rules

Similar to constraint rules in configuration, constraint rules in commerce are set up to warn the buyer when certain attribute values are not allowed. While a constraint is active, the system doesn’t allow the user to advance within the Commerce Process (for example, saving a quote). Once the user has alleviated the constraint, he is allowed to use any displayed commerce actions to proceed through the quoting process. A constraint rule has a condition and an action. When the condition and action are both true, then a constraint is fired, which shows up as a message to the user. Constraints can be written and/or run on attributes in the main-document or sub-document.Example: an attribute value on the main-document could constrain a value in the line item grid and vice-versa.

ClosedAdding a Constraint Rule

Behavior: The time component of date attributes are not supported in commerce rules. Currency attributes with a default of 0.0 are not constrained in a new transaction even if the value is constrained by a rule. You can set up a validation rule to ensure that the transaction cannot be saved with this value. For an integer attribute constraining 0 will not constrain the blank value. If you constrain a currency attribute using a simple constraint rule, then the exchange rate will be taken into account when the attribute is constrained. Example: in a USD base currency site if the constrained value of a currency attribute is 1 and the exchange rate for Euro is 2, then for the Euro user the constrained value will be 2 while for the dollar user, the constrained value will be 1. However, if you use an advanced constraint rule, the exchange rate will not be taken into account. In this case, if the function returns 1 as the constrained value, then the value 1 will be constrained for both the dollar and the Euro user.

You can control whether or not a dialog loading box appears for the constraint and hiding rules by making a settings change within Commerce Settings. For the option ‘Number of Milliseconds to Wait Before Showing the Loading Dialog for AJAX Rules’, enter:


ClosedValidation Rules

Validation rules will validate the attribute values in the context of the current document, and its associated parent/child, when the user clicks an action button. Example: you can write a rule to validate that the user has entered something into the Quote Description. A validation rule has a condition and an action. When the condition is met, the validation runs on the action attribute value(s). Any constrained values will show up as a message to the user. Validations can be written and/or run on attributes in the main-document or sub-document.Example: an attribute value on the main-document could constrain a value in the line item grid and vice-versa.

ClosedAdding a Validation Rule


NOTES

    NULL and blank Integer values are treated as separate values.

    - NULL= 0
    - Blank = ""

    If you use logic that tests for NULL values in rule conditions or BML, this logic should be updated.

    Using "null" as an attribute value is strongly discouraged.

RELATED TOPICS

Related Topics Link IconSee Also