Skip to main content

Create Zuora Rules

Zuora

Create Zuora Rules

Zuora Rules Structure

A rule in Zuora Rules Engine consists of the following components:

  1. Header Information: Includes rule name, description, priority, and active flag.
  2. Trigger Event: Defines specific trigger events that must be met to trigger the rule.
  3. Condition: Defines the condition that must be met for the rule to be triggered.
  4. Actions: Defines what should happen when the rule is triggered.

clipboard_e3822f6f0c205c372a715d84b960535bc.png

Trigger Event

Trigger event refers to the specific event or condition that causes the rule to be executed or triggered. It is the event that initiates the rule's action. The rule is activated when the trigger event occurs, and its associated actions or operations are performed.

The following trigger events are available:

Trigger Event Description
Trigger Rule whenever criteria for the Rule is met This is the default trigger event, where the rule will be executed whenever the specified criteria for the rule are met.
Trigger Rule only when Save or Submit buttons are selected in Quote Studio UI With this trigger event, the rule will be triggered only when you select the Save or Submit buttons in the Quote Studio UI. This allows you to execute the rule at specific points during the quote creation process.
Trigger Rule only when Quote Studio Initially loads This trigger event ensures that the rule is executed only when the Quote Studio initially loads. This can be useful for scenarios where you want the rule to be applied when the quote is first accessed or opened.

It is important to note that upgrading from Version 10.19 to 10.20 might require additional attention. The default trigger event for existing rules may be set to null, potentially affecting their functionality.

To ensure a smooth transition and proper functioning of your existing rules when upgrading from Version 10.19 to 10.20, we recommend performing the following steps:

You can execute the provided code snippet in the developer console to default the trigger event value for your existing rules. This adjustment will ensure your rules continue operating as intended within the enhanced rules engine framework.


List<zqu__ZRule__c> zRuleList = [SELECT Id, Name, zqu__TriggerEvent__c FROM zqu__ZRule__c WHERE zqu__TriggerEvent__c = null];
for (zqu__ZRule__c zRule : zRuleList) {
if (zRule.zqu__TriggerEvent__c == null) {
zRule.zqu__TriggerEvent__c = 'Everytime';
}
}
update zRuleList;

If you are upgrading from version 10.19 to 10.21 or later, you do not need to manually run the code. The system will handle this process automatically for you.

Condition

A Condition is a set of evaluation criteria that operates on a set of data. A Condition determines whether the Actions of the rule should execute.

In the Rules tab, you set up one Quote-level condition for each rule. For example, "Add a Support Product if there are three or more Software plans".

A Criterion in a Condition is made up of Conjunctions and Comparisons.

  • Conjunctions: The AND and OR operators to join two or more Criteria.
    • If a Condition is made up of criteria joined by AND, the rule will execute if ALL of the criteria are true.

    • If a Condition is made up of criteria joined by OR, the rule will execute if ANY of the criteria are true.

  • Comparison: A basic operation of comparing one value to another. A comparison is comprised of a left term, a relational operator, and a right term. 
    • The left term and right term are Values
    • The left term can be compared to the right using one of the following:
      • is equal to
      • is not equal to
      • contains
      • does not contain
      • is null
      • is not null
      • is less than
      • is greater than
      • is less than/equal to
      • is greater than/equal to

Values

Values are the units being compared in Comparison criteria. Both the left and right side operands of each Comparison must contain a value. The following types of Values are supported: 

  • Static Value: A value that you specify when the rule is configured. This value does not change.
  • Object Field Value: References a field on the Quote object. At runtime, the value is retrieved from the object field, e.g. Quote.Type.
    You can also reference a field on any object in the parent hierarchy of the Quote object, e.g. Quote > Opportunity > Account.Industry.
  • Rollup Value: A calculated value that performs an aggregation operation against a collection of records at runtime. For example, Sum of all Prices on Charges with Type 'Software'.
    • A Rollup Value can aggregate values on the Rate Plans, Charges or Features related to the Quote.

    • Rollup Values can be referenced in either calculated values or comparisons and are used to aggregate values based on a collection of data.

    • Operation determines which function to apply against the collection. This can be Count, Sum, Average, Min, Max

    • Rollup Values can make use of a Filter Condition to roll up only a subset of objects. See the Filter Conditions section below.

  • Calculated Value: Values resulted from arithmetic operations against two or more values at runtime. Calculated values can reference any combination of other types of values or arithmetic operations, except for other Calculated Values. For example, 10% of the sum of Hardware and Software charges.
  • System Value: System Values refer to the current users' Profile, User Role, or User information. They can be used to filter which Rules apply to which types of User.
  • Lookup Value: A Lookup value derives a number value by looking up a record of a reference table based on one or many attribute values.
    • Lookup Object Name indicates the custom object that will be used as the lookup table. This object must contain at least one number field.
    • Value Field Name should be set to a number field, which will be the return value of the looked-up record.
    • One or many Attribute values can be set to determine which record of the Lookup object will be used as the value.
    • During rule execution, the value set on each attribute will be evaluated to filter down to one record of the Lookup object, which will be the value of the Value field.
    See Use Case: Setting a Multi-Attribute Price.

Filter Conditions

For actions or aggregations that operate against the Rate Plan, Charge, or Quote Product Feature of the selected Quote, additional child-level Filter Conditions can be set up in the Filter Conditions tab or on the Rules configuration page. Example Filter Conditions could be "Calculate the sum of prices of all charges where Type is Hardware" or "Update all charges where discount is greater than zero".

Actions

A rule has one or more Actions. Each action describes something that should happen when the rule is run. Actions are configured with different attributes depending on the Action type. The supported Action types are:

  • Add Product: Adds a new rate plan to the quote.
  • Remove Product: Removes a rate plan from the Quote.
  • Update Product: Updates a field value of the products matching certain criteria.
  • Show Validation Message: Shows a message that alerts users about invalid conditions in their quote. For the Error type validations, the quote cannot be saved or submitted until the error condition is resolved.
    Info and Warning messages can also be configured that alert the user, but do not prevent it from saving the quote.
  • Custom Action: Use the Custom Action Plugin to define additional rules actions you want the Rules Engine to perform.

Create a Rule in Zuora Quotes

To create a rule in Zuora Quotes:

  1. In the Rules tab, click New or New Rule.
  2. In the RULE section, specify the following field values. 
    • Name: Specify a name to identify this rule. The name of each rule must be unique in your org.
    • Active: Select to activate the rule and have it applied to the quoting process. You can create a rule without initially activating it.
    • Description: Give a description of what the rules does. 
    • Priority: Specify an ordinal number. A rule with the higher Evaluation Priority value is evaluated after a rule with the lower Evaluation Priority value.
  3. In the CONDITION section, click Add Criteria... and specify the following field values.
    1. Conjunction: Toggle between OR and AND to join condition criteria.
    2. Attribute Type of the first operand: Click and select a type. The next input fields depend on the type you select in this field.
      • System Value: Select the Profile, User Role, or User object first. Then select a Field on the that object to filter on.
      • Calculated Value: Click -Select Value- to specify a predefined Formula or create a new Formula.
      • Rollup Value: Select the Object and Rollup Type fields.
      • Object Field Value: Click and select a field on the Quote object. To select a field on the Account, Contact, or Opportunity object, select the lookup reference, e.g. Account >.
    3. Comparison Operator: Click is equal to and select a comparison operator.
    4. Attribute Type of the second operand: Click and select a type. The next input fields depend on the type you select in this field.
      • System Value: Select Profile, User Role, or User object first. Then select a field on the selected object.
      • Calculated Value: Click -Select Value- to specify a predefined Formula or create a new Formula.
      • Rollup Value: Select the Object and Rollup Type fields.
      • Object Field Value: Click and select a field on the Quote object. To select a field on the Account, Contact, or Opportunity object, select the lookup reference, e.g. Account >.
      • Static Value: Specify a constant for the first operand to be compared against.
    5. Click Add Criterion... if you want to add another condition criterion.
  4. In the ACTIONS section, click Add Action... and specify the following field values. A rule can have one or more actions.
    1. In the Action Type field, click and select a type of action to trigger when the above condition met.
      • Update Product
        • Object: Select the object to be updated.
        • Field: Select the field to be updated.
        • Filter: Optionally, click No Filter to select a predefined filter or to create a new filter. This further filters the records to be updated.
        • New Value Type: Select the value type. See above for the description of each value type.
        • Message: Specify the text to be displayed to the user when this action executes. This field value is optional.
      • Remove Product
        • Filter: Optionally, click No Filter to select a predefined filter or to create a new filter. This filter defines which rate plans are to be removed from the quote.
        • Message: Specify the text to be displayed to the user when this action executes. This field value is optional.
      • Add Product
        • Product: Select a product to be added.
        • Rate Plan: Select a rate plan to be added.
        • Removal Behavior: Click and select one of the following options to instruct the Rules Engine what to do when a user tries to remove the product added to a quote by this rule. Your selection is not preserved when the quote is saved. All products on a quote will be re-evaluated when the page is refreshed.
          • Remove and Re-Add: First, the product is removed from the quote, and the rule condition is re-evaluated. If the rule condition is still true, the product is added back to the quote.
          • Require: The product added by this rule cannot be removed by a user. The product can only be removed by other rules.
          • Remove: When a user removes the product added to a quote by this rule, the product is removed from the quote and is not added back to the quote even by another rule. 
             

            At present, regardless of the option chosen for removal behavior, the system consistently executes a "Remove and Re-Add" action. To illustrate, if the "Remove" option is selected in the "Removal Behavior" field, the respective product is removed from the quote. Subsequently, the rule condition is re-evaluated, and if it remains true, the product is added back to the quote.

            We are actively addressing this behavior, and we are in the process of developing updates to rectify the issue. These updates are scheduled for release in the near future

        • Allow Immediate Actions: Select to allow the details of the product added by this action be manipulated by rules that happen immediately after. For example, if you want to add a product then immediately set its price with another action. Gathering the details of added charges has a performance cost, so we recommend using this option only when absolutely necessary.
        • Message: Specify the text to be displayed to the user when this action executes. This field value is optional.
      • Show Validation Message
        • Message Type: Select the message type.
          For the Error type messages, users will not be able to save or submit a quote if the rule condition is evaluated to be true.
          The Info and Warn type messages display informational messages to the user.
        • Message: The text to be added to the log. 
      • Custom Action
        • Class Name: Specify the class name of your Custom Action Plugin that you have implemented.
        • Attribute: The key name of the attribute as defined in the Custom Action Plugin. The key name must match as defined in the plugin code.
        • Value: The values for the attribute key. 
    2. Click Add Action... if you want to add another action for the rule.
  5. Click Save to save the rule and exit. Or Click Quick Save to save the rule and stay on the page.

Create a Filter Condition

To create a Filter Condition to be used in rules:

  1. In the Filter Conditions tab, click New or New Filter Condition.
  2. Alternatively, you can create Filter Conditions on the Rules configuration page.
  3. Specify the following field values:
    • Name: Assign a name to identify the filter. This name will appear in Zuora Rules Engine configuration. The name must be unique across all Filter Conditions in your org.
    • Object Type: Select the object this filter is on. 
  4. In the CONDITION section, click Add Criteria... and specify the following field values.
    1. Conjunction: Toggle between OR and AND to join condition criteria.

    2. Attribute Type of the first operand: Click and select a type. The next input fields depend on the type you select in this field.

      • System Value: Select Profile, User Role, or User object first. Then select a Field on the selected object to filter on.

      • Calculated Value: Click -Select Value- to specify a predefined Formula or create a new Formula.

      • Object Field Value: Click and select a field on the object you selected in the Object Type field.

    3. Comparison Operator: Click is equal to and select a comparison operator.

    4. Attribute Type of the second operand: Click and select a type. The next input fields depend on the type you select in this field.

      • System Value: Select Profile, User Role, or User object first. Then select a field on the selected object.

      • Calculated Value: Click -Select Value- to specify a predefined Formula or create a new Formula.

      • Object Field Value: Click and select a field on the object you selected in the Object Type field.

      • Static Value: Specify a constant for the first operand to be compared against.

  5. Click Add Criterion... if you want to add another condition criterion.

  6. Click Save to save the filter condition and exit. Or Click Quick Save to save the filter condition and stay on the page.

Determine Whether a Rate Plan Charge is Added, Updated, or Original on a Quote 

You can create a Filter Condition to query the Amendment Type field (zqu__AmendmentType__c) on Quote Rate Plan (zqu__QuoteRatePlan__c) to determine whether a charge is new, updated, or original. The values you can query in filter conditions are:

  • NewProduct: This rate plan was added on a new subscription quote or as a new product on an amendment quote.
  • UpdateProduct: This rate plan was updated on an amendment quote.
  • OriginalProduct: This is an existing rate plan that has not been changed on an amendment quote.

Create a Calculated Value

To create a Calculated Value to be used in rules:

  1. In the Calculated Values tab, click New or New Calculated Value.
  2. Alternatively, you can create Calculated Values on the Rules configuration page.
  3. Specify the following field values:
    • Name: Assign a name to identify this calculated value. This name will appear in Zuora Rules Engine configuration. The name must be unique across all Calculated Values in your org.
    • Object Type: Select the object this calculated value is applied to. You can create calculated values on the Quote, Rate Plan, Charge, and Feature objects.
  4. In the FORMULA section, click Add Input... and specify the following field values.
    1. Operator: Click Add to select the calculation method. Add, Subtract, Multiply, and Divide are supported.
    2. Input Type: Click and select a type. The next input fields depend on the type you select in this field.

      • Static Value: Specify a numeric constant that this calculated value always returns.

      • System Value: Select the User object first. Then select a Field on the selected object to grant access to specific users to use this calculated value.

      • Rollup Value: Select the Object and Rollup Type fields.

        • Optionally, click No Filter in the Filter field to select or create a filter. 
      • You can create filters in the Filter Conditions tab prior to this step.

      • Object Field Value: Click -Select Field- to select a field on the base object you selected in the Object Type field. Click Select to choose the field.

  5. Click Save to save the calculated value and exit. Or Click Quick Save to save and stay on the page.