Lifecycle Callback provides you a mechanism to execute custom actions at the following stages in the quote process. class

  • after a proposal is cloned 
  • after an agreement is created from a proposal
  • creates a new proposal from the given account
  • creates a new proposal from the given opportunity
  • clones the given proposal
  • creates a new agreement from the given proposal
  • after a proposal is created from an account
  • after a proposal is created from an opportunity

To use the Lifecycle Callback you must create a custom Apex class that implements the Apttus_Proposal.CustomClass.IQuoteLifecycleCallback2 interface and register the custom apex class with Lifecycle Callback Class. You must write your custom logic in the custom apex class.

You must register the custom apex class for this callback in Lifecycle Callback Class in Proposal Custom Classes instead of Config Custom Classes.

The following methods are available in the Apttus_Proposal.CustomClass.IQuoteLifecycleCallback2 interface:

MethodSignatureDescription
afterClone()void afterClone(Apttus_Proposal__Proposal__c, Apttus_Proposal__Proposal__c)

You can use this method to execute custom logic after the proposal is cloned.

CPQ does not invoke this method when you clone any proposal using the standard Salesforce Clone button. You must create a custom button or a formula field on the Proposal object to invoke this method after cloning a proposal.

afterCreateAgreement()void afterCreateAgreement(Apttus_Proposal__Proposal__c, Apttus__APTS_Agreement__c)

You can use this method to execute custom logic after the agreement is created from proposal.

afterCreateFromAccount()void afterCreateFromAccount(Apttus_Proposal__Proposal__c)

You can use this method to execute custom logic after the proposal is created from account.

CPQ only invokes this method when you execute the Apttus_Proposal.ProposalWebService.afterCreateFromAccount API.

afterCreateFromOpportunity()void afterCreateFromOpportunity(Apttus_Proposal__Proposal__c)

You can use this method to execute custom logic after the proposal is created from opportunity.

CPQ only invokes this method when you execute the Apttus_Proposal.ProposalWebService.afterCreateFromOpportunity API.

afterComplete()void afterComplete(Apttus_Proposal__Proposal__c, Apttus_Proposal.CustomClass.ActionType)You can use this method to execute custom logic after proposal lifecycle is completed.
afterComplete()void afterComplete(Apttus__APTS_Agreement__c, Apttus_Proposal.CustomClass.ActionType)You can use this method to execute custom logic after agreement lifecycle is completed.

Example

You can use this callback to a scenario like:

  • After you create a new proposal from Opportunity, values of Bill To Account and Ship To Account fields should be automatically set from the same fields that are present in the associated account.
  • When you clone a proposal, you should have information about the proposal from which the new proposal was cloned from.

The below code implements the first example mentioned above.

/*
* Quote Life Cycle Call Back - Exmaple 1
* This is use case of executing Quote Life Cycle Call Back.
* Method - afterCreateFromOpportunity() of this class will be called whenever we go to opportunity and click on Create Quote/Proposal button.
* Here, We will set BillToAccount and ShipToAccount fields of newly created proposal by taking info of account from opporunity.
*/
global with sharing class APTS_PS_QuoteLifecycleCallback_UC1
    implements Apttus_Proposal.CustomClass.IQuoteLifecycleCallback2 
{
    
    /**
     * Callback invoked after a quote/proposal is created from an account
     * @param quoteSO the new quote sobject 
     */
    global void afterCreateFromAccount(Apttus_Proposal__Proposal__c quoteSO) {
    }
    
    /**
     * Callback invoked after a quote/proposal is created from an opportunity
     * @param quoteSO the new quote sobject 
     */
    global void afterCreateFromOpportunity(Apttus_Proposal__Proposal__c quoteSO) {
        /* USECASE# 1 */

        String billTOAcc = quoteSO.Apttus_QPConfig__BillToAccountId__c;
        String shipTOAcc = quoteSO.Apttus_QPConfig__ShipToAccountId__c;
        String accId = quoteSO.Apttus_Proposal__Account__c;

        
        if(billTOAcc == null && shipTOAcc == null) {
            billTOAcc = accId;
            shipTOAcc = accId;
        } else if(billTOAcc == null) {
            shipTOAcc = billTOAcc;
        } else if(shipTOAcc == null) {
            billTOAcc = shipTOAcc;
        }
        
        
        quoteSO.Apttus_QPConfig__BillToAccountId__c = billTOAcc;
        quoteSO.Apttus_QPConfig__ShipToAccountId__c = shipTOAcc;

    }
    
    /**
     * Callback invoked after an agreement is created from a quote/proposal
     * @param quoteSO the quote sobject 
     * @param agreementSO the new agreement sobject 
     */
    global void afterCreateAgreement(Apttus_Proposal__Proposal__c quoteSO, Apttus__APTS_Agreement__c agreementSO) {
    }
    
    /**
     * Callback invoked after a quote/proposal is cloned
     * @param originalSO the original quote sobject 
     * @param cloneSO the clone quote sobject
     */
    global void afterClone(Apttus_Proposal__Proposal__c originalSO, Apttus_Proposal__Proposal__c cloneSO) {
    }
    
     /**
     * Callback invoked before a quote/proposal is cloned
     * @param originalSO the original quote sobject 
     * @param cloneSO the clone quote sobject
     */
    global void beforeClone(Apttus_Proposal__Proposal__c originalSO, Apttus_Proposal__Proposal__c cloneSO) {
    }
    
    /**
     * Callback invoked after the completion of a lifecycle action
     * @param quoteSO the quote sobject 
     * @PARAM actionType the lifecycle action type
     */
    global void afterComplete(Apttus_Proposal__Proposal__c quoteSO, Apttus_Proposal.CustomClass.ActionType actionType) {
   }
    
    /**
     * Callback invoked after the completion of a lifecycle action
     * @param agreementSO the agreement sobject 
     * @PARAM actionType the lifecycle action type
     */
    global void afterComplete(Apttus__APTS_Agreement__c agreementSO, Apttus_Proposal.CustomClass.ActionType actionType) {
    }       
}
CODE