Skip to main content

Create Context Rules for Price Lists

Learning Objectives

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

  • Create context rules for price lists.
  • Control which price list displays in the Cart.

More to Context Rules

In the same way that context rules are used to determine eligibility for products and promotions, they’re also used to determine eligibility for price lists and price list entries.

Context rules are assigned to both parent and child price lists. When used with a parent price list, context rules control what price lists users see in the Cart price list dropdown menu. However, when used with a child price list or a price list entry, context rules help determine what price to apply to products in the Cart based on rule criteria such as customer segment or account status.

In this unit, you create context rules to control which price list displays in the Cart.

Creating a Context Dimension

Eliza, our CPQ developer, wants to create two context rules: one that makes the B2C price list available to consumer accounts only and another rule that makes the B2B price list available just to business accounts. She starts by creating a context dimension.

Follow along with Eliza in your training playground.

Previously, you created a context dimension with a picklist for selecting the account status. Here, you create a context dimension that allows free text entry. For this, you must select Type in as the Domain Type. This field records the account type—business or consumer.

  1. On the Vlocity Product Console dashboard, under Rules, click Plus next to Context Dimension.
  2. Enter these details:
  • Name: AccountType
  • Code: DIM_ACCOUNTTYPE. This is used while creating custom expressions and should be unique with no spaces.
  • Data Type: Text
  • Domain Type: Type in
  • Active: selected
  • Effective From: today’s date
  1. Click Save.

The New Context Dimension page with details filled in.

Your context dimension is ready.

Next, create a context mapping on the AccountType context dimension that evaluates the type of account record associated with the order.

  1. On the left sidebar of the open AccountType context dimension, click Context Mappings.
  2. Click New Context Mapping to show the Context Mapping dialog.
  3. Add these details:
  • Context Scope: AnyAccountScope
  • Initialization Policy: Always Reinitialize
  • Initialization Type: Source Expression
  • Source Expression: RecordType.Name. RecordType.Name is the API name of the sObject field that is compared to the value stored in the context dimension.
  • Sequence: 10
  • Active: selected
  • Effective From: today’s date
  1. Click Save.

The Context Mappings page with details filled in.

With both the context dimension and context mapping in place, you can move on to your next step, which is creating context rules.

Defining Context Rules

It’s time to create two context rules, one for consumer accounts and another for non-consumer accounts. Start by creating the consumer accounts rule, which makes the B2C Price List available only when the account associated with an order has a Consumer account type.

  1. On the Vlocity Product Console dashboard, under Rules, click Plus next to Rule.
  2. Set these details in the New Rule dialog:
  • Name: Consumer Accounts
  • Code: RULE_CONSUMER_ACCTS
  • Description: Selects consumer accounts
  • Expression Mode: And
  • Active: selected
  • Effective Start Date: today’s date
  1. Click Save.

The New Consumer Accounts Rule page.

Your context rule is ready. Next, add the conditions.

  1. On the left sidebar of the open Consumer Accounts context rule, click Rule Conditions.
  2. Using the Add Condition dropdown menu, select Simple.
  3. Enter these details in the Rule Condition window:
  • Code: RC_CONSUMER_ACCTS
  • Context Dimension: AccountType. This is the context dimension you created earlier in this unit.
  • Operator: ==
  • Value: Consumer. This is a freeform text entry field due to the Domain Type that is set in the context dimension.
  1. Click Save.

Newly created rule condition specifies that the B2C Price List is available only for Consumer accounts.

Now that you have a rule for consumer accounts that use the B2C Price List, you must create another rule for non-consumer accounts that will use the B2B Price List.

Follow the same steps to create the Consumer Accounts rule, but this time, include a != operator in the rule condition. This specifies that only non-consumer accounts have access to the B2B Price List.

A newly created rule condition specifying that the B2B Price List is available only for Non-Consumer accounts.

You’ve successfully created both the context rules for consumer and non-consumer accounts.

Creating Rule Sets

A rule is associated with a product or service using a rule set. For this business scenario, you create two rule sets—one for the Consumer Accounts rule and the other for the Non-consumer Accounts rule.

  1. On the Vlocity Product Console dashboard, under Rules, click Plus next to Rule Set.
  2. Enter these details:
  • Name: Consumer Accounts Rule Set
  • Rule Type: Qualification
  • Rule Purpose: Eligibility
  • Expression Mode: And
  • Failure Message: Valid only for consumer accounts
  • Active: selected
  • Effective Start Date: today’s date.
  1. Click Save.

Next, gather the required rules into this newly created rule set, which can be added to products, price lists, or price list entries. In this case, you add just one context rule, the Customer Accounts rule you created earlier.

  1. On the left sidebar of the open New Accounts Rule Set, click Children Rules.
  2. Click New Child Rule.
  3. In the General Properties dialog, enter these details:
  • Rule: Customer Accounts
  • Sequence: 10
  • Action Taken: Qualify. This specifies the action to be taken when the rule evaluates to true.
  1. Click Save.

Customer Accounts Rule added to the Consumer Accounts Rule Set.

After creating a rule set for consumer accounts, you’re ready to do the same for non-consumer accounts. Here’s a little hint: take the same steps.

It's important to create two separate rule sets. Otherwise, consumer accounts will see both the B2C and the B2B price lists, which would be confusing.

Time to Test

Before testing your context rules, apply them to the price lists. Price lists are created in Pricing Designer, which you use to open the B2C Price List and apply the Consumer Accounts Rule Set. Then, open the B2B Price List and apply the Business Accounts Rule Set. Here’s how.

  1. From the App Launcher, find and select the Vlocity Pricing Designer.
  2. From the navigation menu, select PriceList.
  3. From the All list view, select the B2C Price List.
  4. In the B2C Price List, select the CONTEXT RULES workspace.
  5. From the RULE SETS list on the right, locate the Consumer Accounts Rule Set and click Plus to add it to the price list.

The Consumer Accounts Rule Set has been added to the B2C Price List.

The Consumer Accounts rule set now displays in the list of applied context rules.

Similarly, follow the same steps to add the Business Accounts Rule Set to the B2B Price List.

Test the Rule in the Cart

With all the context rules framework components defined, you’re ready to put all your hard work to use!

Create a new order for Carole White to test that only the B2C Price List shows up for consumer accounts. Remember to hold off on selecting a price list while creating the order. You’ll soon see why.

In the Catalog workspace of the order, click the Select Price List menu.

B2C Price List is the only price list displayed for Carole White.

Notice that the B2C Price List is the only one that shows. Carole qualifies for this price list because of the Consumer Accounts Rule Set. The reason the B2B Price List doesn’t display is that the Business Accounts Rule Set prevents it.

Similarly, create a new order for Acme. Don’t select any price list initially, as you need to validate if your rule works.

In the Catalog workspace of the order, click the Select Price List menu.

B2B Price List is the only price list displayed for Acme.

Only the B2B Price List displays. Acme qualifies for this price list because of the Business Accounts Rule Set, and the B2C Price List doesn’t display because the Consumer Accounts Rule Set prevents it. Both rules are working as desired in the Cart.

Moving On

You’vecreated context rules to control what price lists customers see in the Cart. In the next unit, you apply rules to price list entries so customers see only the right prices.

Resources

Comparta sus comentarios de Trailhead en la Ayuda de Salesforce.

Nos encantaría saber más sobre su experiencia con Trailhead. Ahora puede acceder al nuevo formulario de comentarios en cualquier momento en el sitio de Ayuda de Salesforce.

Más información Continuar a Compartir comentarios