Skip to main content

Sequence Price Rules for Correct Calculations

Learning Objectives

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

  • Identify what triggers the CPQ calculation sequence.
  • Configure fields to automatically trigger calculation when they are updated.
  • Describe the basic steps of the CPQ calculation sequence.
  • Explain how the Evaluation Event field affects pricing outcomes.
  • Sequence price rules to run in a specific order.

Know When to Expect Calculations

As a part of every exercise in this module, you’ve tested your work by adding products to a quote. The moment you added the product, CPQ ran all pricing calculations, and you could see if the price was what you expected it to be. CPQ runs pricing calculations under a few different circumstances.

  • You add or remove a quote line.
  • You click Calculate, Quick Save, or Save in the Quote Line Editor.
  • You click Calculate on the quote record.
  • You save any change to a quote line record.
  • You save a change to a Calculating Field.

A Calculating Field is one that CPQ knows might affect prices in some way, and therefore should trigger a recalculation. For example, the Subscription Term field is a Calculating Field. Changing the quote from 24 months to 36 months will probably affect pricing. So how does CPQ know which fields are Calculating Fields? Simple, the field is in the Calculating Fields Field Set on the quote object.

Setup showing the quote object field set named Calculating Fields

You can add your own fields to the Calculating Fields by navigating to Setup | Object Manager | Quote | Field Sets | Calculating Fields. For example, imagine that you have a custom checkbox on the quote named “Expedited” and it’s used in a price condition to trigger a rule that adjusts the price of shipping. Just put the field into the Calculating Fields field set. That way, if the checkbox is changed (manually, through automation, or through a bulk upload) CPQ knows to recalculate all prices.

You can remove fields from the Calculating Fields field set, but be careful doing that! You might inadvertently allow prices to go uncalculated when they should be.

Price Rules and the Quote Calculation Sequence

When CPQ calculates a quote, it does a lot of work in the background to make sure all the fields on the quote, quote lines, and quote line groups get the correct values. The steps it takes to perform the calculations happen in a very specific sequence. Here’s an abbreviated list of those steps.

  1. Fetch data from related records (product, option, costs, and so forth)
  2. Run [On Initialization] price rules
  3. Evaluate formula fields (quote lines, quote, and quote line groups in that order)
  4. Run [Before Calculate] price rules
  5. Calculate quote line quantities (for example, bundle components)
  6. Run [On Calculate] price rules
  7. Calculate out-of-the-box pricing tools (block pricing, discount schedules, and so on)
  8. Run [After Calculate] price rules
  9. Evaluate formula fields again (quote lines, quote, and quote line groups in that order)
  10. Calculate totals (on groups and quote)

As you can see CPQ runs price rules four different times! Well, actually, not every price rule runs four times. In fact, most price rules only run once, depending on the price rule’s Evaluation Event field.

Price rule record with the Evaluation Event field highlighted.

As you completed the activities in this badge, you left the Evaluation Event field set to On Calculate for every rule. That means it only ran once per calculate: immediately after CPQ calculated quote line quantities. For most price rules, that’s a fine time to run. But sometimes, a rule will only produce the results you expect if you shift it up or down in the calculation sequence. In that case, you need to change the Evaluation Event.

For example, imagine that you sell a lunch bundle. Every sandwich you make comes with two cookies. So five sandwiches means 10 cookies. CPQ does the quantity math immediately before the On Calculate rules run. Now imagine that you make a price rule that targets the bundled quantity of cookies for special customers, giving them three cookies for every sandwich. Yeah, pretty amazing. But if you leave the rule’s Evaluation Event as On Calculate, it updates the bundle quantity too late since CPQ has already done the math for cookie quantity. Sadly, selling five sandwiches only gives the customer 10 cookies, not 15.

Thankfully, there’s an easy way to resolve this issue. Change the rule’s Evaluation Event to Before Calculate. That way, the change from two to three cookies is picked up when CPQ calculates quote line quantities. Now five sandwiches means 15 cookies.

You’ve probably noticed that Evaluation Event is a multi-select picklist. A single rule can be run more than once during the calculation sequence by adding it to multiple Evaluation Events. That said, we highly recommend limiting rules to just one event, which maximizes system performance.

Concurrent Conditions

When you click Calculate, Salesforce CPQ starts working through the calculation sequence, step by step. Eventually it gets to the On Initialize Evaluation Event. Now imagine there are three rules on that event that could possibly run. CPQ is going to test all three rules’ conditions before taking any actions. So its process would look like this.

  • Test if rule 1 conditions are met [Let’s say yes].
  • Test if rule 2 conditions are met [Let’s say yes].
  • Test if rule 3 conditions are met [Let’s say no].
  • Do rule 1 price actions.
  • Do rule 2 price actions.

Every condition is evaluated before any actions are taken in a given evaluation event. CPQ repeats this process every time it hits one of the four evaluation events. That’s fine most of the time. But it means a problem can occur when you have one rule that targets a field that is used in the condition of a second rule. For example, let’s say you have these two rules.

  1. IF Delivery Date is within 2 weeks, THEN set Expedited to checked.
  2. IF Expedited is checked, THEN add $20 surcharge to shipping.

If these two rules are set up to run on the same event, the second rule will not run! As far as CPQ is concerned, this is what happens.

  • Test if Delivery Date is within 2 weeks? [yes]
  • Test if Expedited is checked? [no]
  • Do rule 1 price actions. (Set Expedited to checked, too late to matter!)

In this scenario, rule 2 actions don’t happen so the shipping price is not updated correctly, which is very bad. Thankfully there’s a solution. You can move the first rule into an earlier evaluation event. Or you could move the second rule into a later evaluation event. Either way, CPQ would then take the action of checking Expedited before evaluating the condition of the second rule.

There’s an obvious way to tell if your price rules suffer from this issue—the only way you can get the expected price to appear is by clicking Calculate more than once. That causes CPQ to run through the calculation sequence again and again. In the shipping price example, the first click of Calculate would set Expedited to true (but not adjust shipping). The second click of Calculate would see that Expedited is true, and then adjust shipping.

Here’s the problem: You can never guarantee that your sales reps will click the Calculate button enough times. For that reason, it is completely unacceptable to rely on multiple clicks of Calculate to get the right price. If you discover that’s happening, consider moving a rule into another evaluation event.

Order Around Your Actions

Sometimes you’ll have two price actions that work together for a cascaded result. For example, you might have these two actions in the same rule.

  1. Set List Price to $535.
  2. Set Max Discount Amount to (List Price - Cost).

In this case, you’d want 1 to occur before 2 so that 2 has an updated List Price to use in its calculation. You can force actions to calculate in a specific order by numbering them using the Order field on the price action record. CPQ calculates actions in numeric order.

Price action record with the Order field highlighted.

Similarly, price rule records have an Evaluation Order field that you can use to sequence rules that run in the same evaluation event. That means there are three ways to govern when actions are taken, in this priority:

  1. Price rule’s Evaluation Event
  2. Price rule’s Evaluation Order
  3. Price action’s Order

So, imagine you have these three rules, each with a price action. Which one would run first?

Rule A Rule B Rule C

Evaluation Event: On Calculate


Evaluation Order: 3


Price Action Order: 20

Evaluation Event: On Calculate


Evaluation Order: 2


Price Action Order: 30

Evaluation Event: After Calculate


Evaluation Order: 1


Price Action Order: 10

You can immediately throw out Rule C because its Evaluation Event occurs later than the others. That means the price action for Rule B would be calculated first. Rule B’s Evaluation Order of 2 places it before Rule A. It doesn’t matter that Rule A’s action has an Order value that’s numerically before Rule B’s, the rule-level Evaluation Order takes precedence.

Salesforce CPQ gives you a lot of control over when your price rules take effect. Use that power to make sure prices are calculated correctly the first time CPQ runs the calculation sequence.

Price rules are great for precise product pricing, regardless of what kinds of unique reasons your business might have for pricing exceptions. Have fun making price rules do your bidding. And remember, always test your work!

Resources

继续免费学习!
注册帐户以继续。
有什么适合您的内容?
  • 为您的职业目标获取个性化推荐
  • 通过实践挑战和测验练习您的技能
  • 跟踪并与雇主分享您的进度
  • 与人联系以获取指导和就业机会