Filter Discount Schedules by Records and Fields
Learning Objectives
After completing this unit, you’ll be able to:
- Set limits for which records are counted in discount schedule sums.
- Describe how to use a non quantity field to determine the correct discount tier.
Introduction
As you saw in the last unit, Salesforce CPQ can aggregate quantities from multiple records across orders to determine the right discount tier to use for a discount schedule. However, there are times when we don’t want every single record to count toward the total quantity. For example, a cross order schedule tells CPQ to aggregate every asset that exists on the account, but AW Computing wants only those assets purchased in the last 365 days to count. With a little work it is possible to filter which asset records are included in the aggregated sum.
Distinguish Old and New Assets
The first step in filtering records is to distinguish which assets have been purchased in the last 365 days. In this example, AW Computing has diligently maintained an asset field named Purchase Date over the years. You use this information to create a custom formula checkbox field named Purchased This Year, which returns “True” when the Purchase Date is less than 365 days from today’s date.
- Click and click Setup. The Setup page opens in a new tab.
- Click Object Manager.
- Click Asset.
- Click Fields & Relationships.
- Click New.
Your new field is going to be a Formula field since it automatically works out the age of the asset. - Choose Formula, then click Next.
- For the Field Label, enter
Purchased This Year
. - Choose Checkbox as the Formula Return Type, then click Next.
Here we see the formula editor, which is used to determine how the field gets its value. We need a formula that checks if it’s been 365 days since the purchase date. - Type or paste this into the formula window:
TODAY() - PurchaseDate < 365
- Click Next.
- Click Next to keep field-level security as is.
- Click Save.
Now every asset purchased in the last 365 days will have the custom field named Purchased This Year automatically checked, while assets older than a year will be unchecked. Now that asset records are separated into two distinct groups, it is much easier to filter which are included in aggregate quantities.
Create an Answer Key
At this point, we humans know that when Purchased This Year is checked the asset should be included in the aggregated sum, but CPQ doesn’t know that yet. Our next challenge is to put what we know into a format that CPQ can understand. We do so by making an answer key that contains the correct answer for the question: “Which value of Purchased This Year means we should include the asset in aggregation?”
The answer key takes the form of a custom field on the quote object. You create a text formula field that always returns the word “True” since that is the correct answer to our question posed above.
- While in the Setup tab, click Object Manager.
- Click Quote.
- Click Fields & Relationships.
- Click New.
- Choose Formula, then click Next.
The name of our answer key field is very important. It must be the same as the asset field containing the answers we’re checking against. In other words, using the same field name links the answer key to the answers. - For the Field Label, enter
Purchased This Year
. - Choose Text, then click Next.
The formula may be one of the simplest formulas you’ve ever written: It’s just the answer to the question “Which value of Purchased This Year means we should include the asset in aggregation?” - Enter
"true"
(including inch marks) into the formula window. - Click Next.
- Click Next to keep field-level security as is.
- Click Save.
Update Discount Schedule Constraint Field
So far, so good. In the first step, you created a field that distinguishes new assets from old. In the second step, you made an answer key that identifies which assets should be included in aggregate sums. The final step is to update the Bulk Keys discount schedule to use the answer key as a way of filtering asset records by their Purchased This Year value.
- While in the Setup tab, click Object Manager.
- Click Discount Schedule.
- Click Fields & Relationships.
- Click Constraint Field.
- In the Values list, click New.
- Type or paste
Purchased_This_Year__c
into the picklist values window.
It’s extremely important to use the exact API name of the Purchased This Year field, because CPQ throws an error message in the Quote Line Editor if it can’t find the field it’s looking for. - Click Save.
Close the Setup browser tab to return to the Salesforce CPQ app. - Click Discount Schedule from the navigation bar.
- Click Bulk Keys.
- Click Edit.
- Check the Cross Orders checkbox.
- For the Constraint Field, choose Purchased_This_Year__c.
- Click Save.
By setting the Constraint Field to Purchased_This_Year__c, you’ve told CPQ which answer key to use when determining the assets to include when aggregating quantities. Now only assets purchased within the last year count toward the discount tier quantity.
Test Your Work
You can see if only new assets are included in the discount schedule by adding RFID key cards to a quote for University of Arizona, a customer who has purchased key cards two times in the past.
- Click Accounts from the navigation bar, then choose the All Accounts list view.
- Click University of Arizona.
- Click the Related tab.
If you scroll to the Assets related list, you can see that there are two RFID Key Card assets, but only 50 were purchased within the last year. The older 80 key cards shouldn’t be counted toward the discount schedule. - Click Q-00020 from the Quote related list.
- Click Edit Lines.
- Click Add Products.
- Check the box for the RFID Key Card.
- Click Select.
Once the Quote Line Editor loads, you should see that the key card is still full price at $1.00, meaning that the old key cards aren’t being counted. - Change the quantity to
50
, then click Calculate.
Now the 50 key cards from this quote line and the 50 from key cards purchased a few weeks ago are combined, which qualifies for the 10% discount. - Click Save.
Excellent, you now know that only key cards purchased within the last year count toward the discount schedule tier. For this example, we used Purchase Date to drive the formula field that distinguishes one group of assets from another, but you can use any information on the asset record, making the Discount Schedule Constraint Field quite a versatile tool.
Quote Line Quantity Field
By default, Salesforce CPQ uses the Quantity field on the quote line to determine which discount tier to use. This works well in most cases, but there are times when you don’t actually want to use the quote line quantity.
Imagine this scenario: AW Computing wants to give a discount on RFID Key Cards, but it wants to base the discount on how many door locks are sold, not how many key cards are sold. For example, if the customer buys more than 30 door locks, they get a 5% discount on key cards. In this case, the quantity of key cards is irrelevant.
Salesforce CPQ supports this scenario with just a little setup.
- First, you create a custom numeric field on the Quote Line object. You can call it Total_Locks__c.
- Second, you update the value of Total_Locks__c for every RFID Key Card quote line record. (A price rule works nicely here, but that is beyond the scope of this module).
- Third, you update the Bulk Keys Discount Schedule to choose Total_Locks__c for the Quote Line Quantity Field picklist (after adding Total_Locks__c as a picklist value).
While it takes some work to set up the Quote Line Quantity Field field, the effort allows you to support special cases where the Quantity field isn’t the right fit. Now that we have explored how to control what quantities are included in discount schedules, let’s look at some advanced ways to affect volume-based pricing.