CPQ: Refresh Quote Prices as triggering action

CPQ: Refresh Quote Prices as triggering action

On March 3, 2025, Posted by , In Salesforce Technical Questions, With Comments Off on CPQ: Refresh Quote Prices as triggering action
CPQ Refresh Quote Prices as triggering action

Question:

When clicking “Refresh Prices” on a Salesforce CPQ Quote, does this action update any field on the Quote or any related object? Is there any way to track or timestamp this action to reflect that the prices were refreshed? My goal is to show a conditional button on the Quote when the prices have been refreshed using the CPQ “Refresh Prices” button.

Unlock your Salesforce potential with expert-led training enroll now for a demo session in India. Salesforce training in India Start your journey to mastering Salesforce at the best training destination.

Answer:

To achieve the desired functionality of displaying a conditional button after a price refresh, you can implement a custom solution. One approach involves adding a custom field to the Quote object to track this action and updating it via automation. Here is a step-by-step guide:

1.Create a Custom Field

Add a custom checkbox field on the Quote object, e.g., Prices_Refreshed__c.

2.Automation with a Flow or Process Builder

You can create a Flow or Process Builder that is triggered whenever a “Refresh Prices” action occurs. Since the action itself does not modify a field directly, you can identify indirect triggers, such as changes to the Quote Line object or recalculated totals on the Quote.

3.Custom Button Visibility

Use the custom checkbox Prices_Refreshed__c to control the visibility of the button. Add conditional logic in your component, page layout, or Lightning Web Component (LWC) to display the button only when the field is checked.
Example LWC logic:

import { LightningElement, api } from 'lwc';
import getQuote from '@salesforce/apex/QuoteController.getQuote';

export default class ConditionalButton extends LightningElement {
    @api recordId;
    showButton = false;

    connectedCallback() {
        getQuote({ quoteId: this.recordId })
            .then(result => {
                this.showButton = result.Prices_Refreshed__c;
            })
            .catch(error => {
                console.error('Error fetching quote:', error);
            });
    }
}

Code Explanation:

This Lightning Web Component (LWC) fetches a Quote record based on its recordId using an Apex method (getQuote) and checks the value of the Prices_Refreshed__c field. The connectedCallback lifecycle hook triggers the Apex call when the component is loaded. If the Prices_Refreshed__c field is true, the showButton property is set to true, making a conditional button visible in the UI. Any errors during the Apex call are logged to the browser console for debugging.

4.Optional Apex Trigger for Advanced Tracking

If you need more precise tracking, you can create an Apex trigger on the QuoteLine or Quote object. The trigger can identify significant changes after the “Refresh Prices” action and update the custom field accordingly.

Example trigger snippet:

trigger UpdateQuoteAfterPriceRefresh on Quote (after update) {
    for (Quote quote : Trigger.new) {
        if (quote.TotalPrice != Trigger.oldMap.get(quote.Id).TotalPrice) {
            quote.Prices_Refreshed__c = true;
        }
    }
}

Code Explanation:

This Apex trigger runs after a Quote record is updated. It iterates through the updated Quote records in Trigger.new and compares the TotalPrice field with the old value from Trigger.oldMap. If the TotalPrice has changed, it sets the custom checkbox field Prices_Refreshed__c to true. This indicates that the prices were refreshed, enabling tracking of the “Refresh Prices” action.

By implementing this solution, you can track the “Refresh Prices” action and use this information to conditionally display buttons or perform other business logic.

Summing Up

The “Refresh Prices” action in Salesforce CPQ recalculates pricing for a Quote but does not natively record or timestamp the event, posing challenges for tracking. To address this, you can implement a custom solution by creating a field, such as Prices_Refreshed__c, and updating it through automation, such as a Flow, Process Builder, or Apex Trigger, based on changes to the Quote or Quote Lines. This enables tracking of the price refresh and allows conditional actions, like displaying custom buttons, providing a practical workaround to enhance CPQ functionality and meet specific business requirements.

Start Learning Salesforce with CRS Info Solutions

Looking to advance your career in Salesforce? CRS Info Solutions offers comprehensive Salesforce training in India, designed to equip you with the skills needed to thrive in the dynamic Salesforce ecosystem. Our expert trainers bring years of industry experience, offering in-depth courses covering Salesforce Admin, Developer, and AI modules. We focus on real-time project scenarios, giving you the practical, hands-on experience that makes you industry-ready. Whether you’re a beginner or an experienced professional, our structured learning approach ensures you gain the knowledge and confidence to succeed.

Our Salesforce training in India is not just about theory but practical application. With personalized mentorship and detailed class notes, we prepare you for real-world challenges. We also provide expert certification guidance and in-depth interview preparation, ensuring you’re fully equipped to secure a Salesforce role. Join us today for a free demo class and take the first step toward transforming your career with Salesforce!

Comments are closed.