Skip to main content

Restore Modified Attributes

Learning Objectives

After completing this unit, you’ll be able to:

  • Implement a rule to restore modified attributes to their original state.
  • Create evaluation and qualification entity filters.

Restore Attributes to Their Original State

Earlier in this module, Eliza, the CPQ developer at Infiwave, created an advanced rule to modify the attributes of the Broadband Cable Service product at run time. This protects customers from incompatible attribute choices. However, she soon learns that there’s a glitch in this implementation. When customers remove the product that triggers the attribute modification, the modified attributes don’t return to their original state. Eliza realizes she must create a new rule to restore attributes when removing the product from the Cart.

Take a minute or two to understand the impact of creating rules without having a counter-action rule. Open the same order, with the Broadband Cable Service and Business Video Service products as line items in the Cart. Delete the Business Video Service product from the Cart. Now, open the configuration pane of the Broadband Cable Service product to view the Download Speed picklist values. Notice that the attribute picklist values remain modified even though you removed Business Video Service. It only lists 200 Mbps as the available download speed. This is because the actual underlying JSON structure is modified.

The Download Speed attribute of the Broadband Cable Service product showing only 200 Mbps as a picklist value.

To paraphrase Sir Isaac Newton’s Third Law, for every action that changes something in the Cart, there must be an equal and opposite reaction. As a matter of cosmic history, it’s easier to destroy than to create, and this is no different.

Create the Product Relationship

As mentioned earlier, Eliza must create a rule that restores the amended product to its original state. She starts by cloning the existing Business Video Modifies Broadband Cable Attributes product relationship and renames it Business Video Restores Broadband Cable Attributes. This new product relationship performs actions to restore all the original Download Speed attribute values.

Follow along with Eliza in your training playground.

  1. From the Product Relationships view, select Business Video Modifies Broadband Cable Attributes.
  2. In the product relationship header, click Action menu and select Clone.
    The Clone option for the Business Video Modifies Broadband Cable Attributes product relationship.
  1. In the New Product Relationship page, change these details.
    • In the Product Relationship Name field, enter Restore Broadband Cable Attributes.
    • For Product, select Broadband Cable Service.
    • For Related Product, delete Broadband Cable Service.
    • In the Action Parameters field, change all the instances of exclude to include in the existing code.
      The Restore Broadband Cable Attributes product relationship page.
  2. Save your changes.

You have successfully created a product relationship that restores the Broadband Cable Service product’s modified attributes.

Create Entity Filters

Entity filters create the context for rules by filtering order line items and searching for defined conditions. Entity filters consist of one or more conditions that evaluate fields or attributes on an object and, if true, apply a rule action. This rule action can be a product relationship, a matrix, a calculation, or a procedure. Rules can contain one filter or many filters, depending on the business logic that the rule implements.

For example, a filter to identify premises with a service activation date of 45 days or less. Filters are reusable and additive. Once created, they are available for use in any rule.

In this section, you work with two types of entity filters: evaluation and qualification entity filters.

Create an Evaluation Entity Filter

With her new product relationship in place, Eliza realizes the tricky part—she needs the product relationship to trigger only when Business Video Service doesn’t exist in the Cart. As it turns out, checking for the nonexistence of something is more difficult than checking for its existence. To fulfill the requirement, she creates a compound entity filter that chains an evaluation entity filter with a qualification entity filter.

You don’t use evaluation entity filters directly in rule building. Instead, they are internal filters to qualification entity filters. You soon learn how. These entity filters evaluate if all, any, or none of the record sets satisfy certain conditions. They accept a list of items as input and return true or false as the output. For example, an evaluation filter evaluates to true if any of the product’s children has a maximum quantity of less than ten and a minimum quantity larger than two.

Here’s how you create an evaluation entity filter to test for Business Video Service in each line item of the Cart.

  1. From the App Launcher, find and select Vlocity Entity Filters.
  2. Click New.
  3. In the New Vlocity Entity Filter page, provide these details.
    • In the Entity Filter Name field, enter EVAL Is Business Video a line item.
    • For Filter On Object Name, select Order Product<OrderItem>.
    • For Type, select Evaluation.
    • In the Valid From field, select today’s date.
    • For Evaluation Criteria, select None.
    • Save your changes.

The New Vlocity Entity Filter page.

Here, you set the Evaluation Criteria as None to specify the criteria in which the filter must return True. In this case, it says that if none of the line items are Business Video Service, all the line items have satisfied the condition and thus can be passed directly to the rules engine.

Next, chain the new evaluation entity filter to a qualification entity filter that prepares the list of input items for evaluation and, when true, passes the list of qualified items to the rules engine. Here’s how you create the conditions for the entity filter.

  1. In the EVAL Is Business Video a line item page, under Entity Filter Conditions, click Add.
  2. For the Field/Attribute/Related Object field, click Select.
  3. In the Field Selection window, select Price Book Entry ID, and then select Product Name<Name>.
  4. Save your changes.

The Field Selection window for the entity filter condition.

  1. For Operator/Field, select =.
  2. In the Value field, enter Business Video Service.

The entity filter condition that tests for Business Video Service in each line item of the Cart.

  1. Save your changes.

Create a Compound Qualification Entity Filter

A compound filter acts on the order items, returning the item if the entity filter condition is true. The filter condition is the evaluation filter you created earlier. In other words, the filter returns a list of items from the Cart named Business Video Service.

Here’s how to create the compound filter.

  1. In the Vlocity Entity Filters page, click New.
  2. In the New Vlocity Entity Filter page, provide these details.
    • In the Entity Filter Name field, enter Check Cart for Business Video.
    • For Filter On Object Name, select Order Product<OrderItem>.
    • For Type, select Qualification.
    • In the Valid From field, select today’s date.
    • Save your changes.

Next, you create the conditions for the entity filter.

  1. Under Entity Filter Conditions, click Add.
  2. For Type, select Function.
  3. For Field/Attribute/Related Object, select Items in cart.
  4. For Value, enter EVAL and select EVAL Is Business Video a line item.
  5. Save your changes.

The compound qualification entity filter page.

You have successfully created both your entity filters.

Create and Test the Advanced Rule

With the product relationship and entity filters in place, it's time to connect the dots by creating an advanced rule that restores the modified attributes of the Broadband Cable Service Product to their original state.

  1. From the App Launcher, find and select Vlocity Rules.
  2. Click New.
  3. In the New Vlocity Rule page, add these details.
    • In the Rule Name field, enter Attribute Reverse Mods Actions Rule.
    • In the next line, for the three dropdowns, select Configuration, Order Product<OrderItem>, and Active respectively.

The rule name and definition of the Attribute Reverse Mods Actions Rule.

Next, add the product relationship that appears as actions within the Vlocity Rule Builder.

  1. In the Filters And Actions List, click Actions to view all the product relationships.
  2. Locate Restore Broadband Cable Attributes, and click Add To Rule Action.

The Restore Broadband Cable Attributes product relationship added as an action in the Attribute Reverse Mods Actions Rule.

  1. To improve the reusability of this rule, add the Check Cart for Business Video filter as a modifier for the Restore Broadband Cable Attributes action.
    • Under Filters And Actions List, click Filters.
    • Next to FILTERS in the search box, enter check.
    • Click the Check Cart for Business Video filter and drag it over the Restore Broadband Cable Attributes action. The filter now displays as an action modifier.

The Check Cart for Business Video filter acting as an action modifier for Restore Broadband Cable Attributes.

  • Save your changes.

By using the filter as a modifier to the action, you increase the reusability of this rule. You can add multiple actions to this one rule, and each action only triggers for records qualified by the attached filter.

Test the Rule in the Cart

It’s time to test whether the advanced rule works as desired. As a best practice, run the necessary maintenance jobs after creating the rule.

  1. Open the same order that you created in the last unit. This order contains both the Business Video Service and Broadband Cable Service products.
  2. From the Broadband Cable Service action menu, select Configure.
  3. Click Download Speed. You see only one picklist value, 200 Mbps.
  4. Close the configuration window.
  5. Delete the Business Video Service product from the Cart.
  6. Then, open the configuration window of the Broadband Cable Service product.

The Download Speed attribute of the Broadband Cable Service product showing all four picklist options.

Notice that all the Download Speed attribute picklist values have been restored. Mission accomplished!

In this unit, you used evaluation and qualification entity filters to create advanced rules and reverse attribute modification. Next, move on to create advanced rules for Auto-Add relationship type.

Comparta sus comentarios sobre Trailhead en la Ayuda de Salesforce.

Nos encantaría conocer su experiencia con Trailhead. Ahora puede acceder al nuevo formulario de comentarios cuando quiera desde el sitio de la Ayuda de Salesforce.

Más información Continuar para compartir comentarios