CPQ Ninja: Disable subscription proration calculations for specific products

Configuring products in Salesforce CPQ is one of the most challenging tasks in the platform. It is extremely important to set up your pricing model correctly to allow your organization to use CPQ to its full potential without a lot of customizations. In this document I will cover a very common pricing scenario where it is necessary to disable the proration factor of CPQ renewable products to allow for fine grain control of a fixed price over the term of a contract.

Renewal products in CPQ are pretty straightforward, you normally have a few settings to play with:

  • Subscription Type: Defines if your product will be considered a subscription. Options are one-time and renewable.
  • Subscription Pricing: Defines how to calculate the price of the subscription. Percent of Total allows CPQ to calculate the price of this product based on other products in the quote. Fixed price will use the price in the price book.
  • Subscription Term: The base number of months or days represented by the price book price.

In most situations the options above will cover common scenarios, however, in some industries it is necessary to sell renewable products that have a fixed price independent of the duration of the contract. A perfect example is when dealing with account credits. In this scenario, customers should be able to buy credits at a fixed price of $300. These credits can be used anytime during the term of the contract and should be renewable. Consider the following product:

Product: Credits
Subscription Type: Renewable
Subscription Pricing: Fixed
Subscription Term: 12
Price in Pricebook: 300 USD

In the product configuration above, adding the product to the quote line editor with a term of 24 months will double the price to 600 USD per standard configuration:

To avoid this behavior and make the fixed price independent of the term, we will need to disable proration following the instructions in this guide.

Please note that there is no comprehensive official documentation on the Calculator plugin field “calculateFullTermPrice” used in this example. Proceed with caution keeping in mind that CPQ might stop supporting this approach without notice.
Credit for the approach goes to Josh Rivera for first mentioning this idea in the Idea Exchange here.

Create a field on the Product object to disable proration

To keep our approach as maintainable as possible, create a field in the product object to control this behavior. This should be a custom field of type checkbox and will allow your team to control which products will ignore proration. In this example we will use the following template:

Object: Product (API: Product2)
Field Label: Disable Proration
Field API name: DisableProration__c
Type: Checkbox

Creating a field will allow you to check and uncheck this field to control the proration behavior without changing your code.

2022 Update – Create a twin field on the Quote Line object

As per April 2022 it is now required for a custom field to be available in the Quote or Quote Line object to be accessible by the Quote Calculator Plugin.


The easiest way to make this field accessible is by creating a “twin field” in the Quote Line object. Twin fields leverage out of the box CPQ automation to propagate field values from Product to Quote Lines (see more on Twin fields here). For the twin field to work, the same API name as the product field needs to be used so following our example create a field as shown below:

Object: Quote Line (API: SBQQ__QuoteLine__c)
Field Label: Disable Proration
Field API name: DisableProration__c
Type: Checkbox

Leverage the Quote Calculator Plugin to disable proration

The quote calculator plugin (QCP) is a powerful CPQ tool that allows you to perform specialized customizations of the CPQ platform. The QCP leverages the out of the box CPQ framework within the calculation lifecycle for efficiency and scalability purposes. You can explore more about the QCP here, for our purpose we will use only basic customization functionality.

1. Navigate to the “Custom Scripts” Object. This object comes natively with CPQ and can be used to store QCP scripts.

2. Create a record in Custom Scripts and select a name. In this example we will use “ScriptDisableProration”

3. In the Code field use the following script as a baseline and customize it to your needs:

export function onInit(quoteLineModels) {
    if (!quoteLineModels) {
        return Promise.resolve();
    }
    for (var i = 0; i < quoteLineModels.length; i++) {
        if (quoteLineModels[i].record["DisableProration__c"]) {
            quoteLineModels[i].calculateFullTermPrice = true;
        }
    }
    return Promise.resolve();
};

The above script will fire on initialization of the calculation sequence and iterate through all the quote lines. If the quote line product has the checkbox we created checked, then the calculateFullTermPrice property will be activated to indicate CPQ to ignore the out of the box proration logic.

Your script should look something like this:

4. To enable your script to run, navigate to the Installed Packages configuration under Setup > Installed Packages > Salesforce CPQ Configuration

5. In the Plugins tab, enter the Record Name created in step 2

Now go to your quote line editor and test by changing the term on your quote line. Notice that the price will not change when the term is updated.

2022 Update: For twin fields to take effect on existing quotes, quote lines need to be recreated to the line editor. To test, delete your quote line and add it again.

About me

Article by Stefan Zepeda
Hands-on Technical Architect and Salesforce enthusiast with experience collecting requirements, transforming them into solutions and implementing them efficiently on any tehcnology platform.

13 thoughts on “CPQ Ninja: Disable subscription proration calculations for specific products

    • Hi Riley, I haven’t tested this with MDQ. Did you end up creating a new field for this? I have seen some users have issues if the field is not used in another price rule. To test you can modify the plugin to check for a sku number to test

      Like

      • I created a new field for DisableProation on the Product level. Do I need to create the same field on the quote line level?

        Like

  1. In order for this to work you need to explicitly tell CPQ to populate your “DisableProration__c” field on the quote line record using the “Quote Line Fields” field on the custom script record. I don’t know off the top of my head whether you can specify fields on related records (like “SBQQ__Product__r.DisableProration__c”), but you can create a twin field for “DisableProration__c” on the SBQQ__QuoteLine__c object and then specify it in the custom script record so that CPQ populates it. Without doing that your javascript conditional ‘quoteLineModels[i].record[“SBQQ__Product__r”][“DisableProration__c”]’ will always be false.

    Like

    • Thanks Chad! You are correct, I have heard reports of the “Quote Line Fields” dot notation not working in newer versions of CPQ. Will update the guide, it seems that adding a twin field is the cleanest way to go about it since you probably would want to report on this anyway. Thanks again for posting!

      Like

  2. Hi Stefan, I followed through your steps and also created the twin field on the Quote line object but it still does not work. Is there any thing else I might be missing?

    Like

  3. Hi Stefan
    I am trying the same functionality in my products however I couldn’t see the custom field I have created on the product object in the Custom script code.
    It seems the field is not accessible. Can you please confirm what I am missing here?

    Like

    • Hi Abhi, i updated the blog post today to include an extra step required in recent versions. Now you need to create a twin field on the quote line to make your field visible in the custom script. Let me know if that works for you.

      Like

  4. 2 Questions, (heads up. I’m not a developer). Firstly, there is already a custom script plugged in and which handles a completely different calculation (it’s basing the quantity of a line on the total net value of core items on the quote). Since there is only one place to add the QCP, can I combine that script and this script in the same custom script? Secondly, if our product only needs to avoid proration on amendment quotes, will controlling the “DisableProration__c” value at the Quote Line level allow for the Product level to remain subject to proration for other quote types?

    Like

  5. Hi Stefan, I followed your steps and also created the twin field on the Quote line object but it still does not work.
    Is there any thing i missed?

    Like

    • Hey Gaurav, which CPQ version are you on? Quick things to check:
      1. Make sure your twin fields match properly, confirm by adding it to the Qouteline layout to make sure it looks checked
      2. Make sure the QCP is added in the package settings. If you have a QCP already, you will need to merge the code in the right place.
      3. One final way to test is to remove from the QCP the Disableproration__c test for a few minutes. Then check again, this will disable proration for all your quotelines but is an easy fast way to narrow down the issue to your twin field.

      Like

Leave a comment