0

I have a request to customize the CPQ Clone Line function within the Quote Line Editor. The default behavior of the clone function is that all fields on a quote line are copied during a clone line operation. Instead, we'd like to have the clone line function copy most fields, but clear out certain fields related to approvals stored on the quote line.

Is there any way to customize the clone line operation?

Or is it possible to build a custom clone line operation?

I am not seeing a way to use Custom Actions, Price Rules, or Product Rules to create a custom Clone Line function.

I cannot use triggers because the clone function happens in the Quote Line Editor GUI and the quote line being cloned may not be stored in the database yet.

Approaches investigated:

  1. Creating a new Custom Action that only copies some fields - does not appear any way to do this.
  2. Price rule that clears out some fields upon cloning - no way to differentiate new lines from existing lines.
  3. Custom Script to clear out some fields upon cloning - no way to differentiate new lines from existing lines.

Thanks, Mike

1

Use of Custom Action Plugin and the onAfterCloneLine method provided result. Salesforce documentation provided here: https://developer.salesforce.com/docs/atlas.en-us.cpq_dev_api.meta/cpq_dev_api/cpq_custom_action_plugin.htm

onAfterCloneLine method allows you to modify lines that have been cloned.

Use console.log statement and Chrome inspector to see structure of 'clonedLines'.

Example below sets 'Line_Item_Approval__c' field to false for all cloned lines.

Must handle standard and segmented lines separately as shown in code below.

For segmented lines, must use correct notation depending on how segmented lines are segmented in your CPQ installation. Example below modifies segmented lines that have been segmented by Year, but there are other segmentation methods available.

export function onAfterCloneLine(quote, clonedLines) {
    console.log(clonedLines);
    clonedLines.clonedLines.standard.forEach(function(line){
        line.record['Line_Item_Approval__c']=false;
    });
    clonedLines.clonedLines.segmented.Year.forEach(function(line){
        line.record['Line_Item_Approval__c']=false;
    });
    return Promise.resolve();
 }

Unfortunately, this approach does not seem to work for the Clone Group functionality. Selecting Clone Group does not appear to fire the onAfterCloneLine method.

Idea to expand this functionality to Clone Groups: https://success.salesforce.com/ideaView?id=0873A0000003hAFQAY

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.