Loading

Salesforce CPQ Order Management Plugin

Date de publication: Sep 27, 2025
Description

An Order Management Plugin is used to set the Order's Start Date. A Quote ID is passed into the plugin and a Date is returned.

An example plugin is one that delays the Order Start Date by a specified number of days using a field on the Quote. The plugin queries for the field value from the Quote, adds that number of days to the current system date, and returns the modified Order Start Date.

The name of the Apex class for the Order Management Plugin is configured via this path:

Setup > Installed Packages > Salesforce CPQ > Configure > Plugins > Order Management Plugin.


The 'Default Order Start Date' value must be set to "-- None --", otherwise the date value overrides the plugin's functionality:

Setup > installed Packages > Salesforce CPQ > Configure > Order > Default Order Start Date


NOTE: The date returned by the plugin will be used for all Orders that are generated in that pass. If you're using the auto-split functionality to split the quote and generate multiple orders, the plugin code doesn't support use cases requiring different start dates on order products.

Résolution
/** 
 * Class Name: OrderPlugin
 * Description: Order Management Plugin used in Salesforce CPQ to calculate custom Order start date.
 * Author: Greg Mlynarczyk
 * 
 * Modification Log:
 * Version    Date        Author                Modification
 * 1          2017-05-05  Greg Mlynarczyk       Created.
 */

global class OrderPlugin implements SBQQ.OrderManagementPlugin{
    
    public Date getOrderStartDate(Id quoteId) {
    
        Date orderStart;
        
        //Query for Quote that matches provided record ID and retrieve the Delayed Start Days field
        SBQQ__Quote__c theQuote = [SELECT Id, Delayed_Start_Days__c FROM SBQQ__Quote__c WHERE Id = :quoteId LIMIT 1];
        
        //Add the specified number of days to today's date. If no Delayed Start value is populated, treat as zero.
        if(theQuote.Delayed_Start_Days__c == null) {
            orderStart = system.today();
            system.debug('No Delayed Start populated. Using current system date.');
        } else {
            orderStart = system.today().addDays(theQuote.Delayed_Start_Days__c.intValue());
            system.debug('Found Delayed Start of ' + theQuote.Delayed_Start_Days__c.intValue() + '. Order Start date calculated to be ' + orderStart + '.');
        }
        
        return(orderStart);
    }
}
Numéro d’article de la base de connaissances

000384532

 
Chargement
Salesforce Help | Article