Happy Business Starts Here

Question on Clone Quote

Highlighted
Support SME

Question on Clone Quote

Problem:

 

Customer would like to know whether the clone quote functionality can be customized. Following are some high level requirements.

Consider the 3 different Quotes (new, amend, renew) . Determine what fields/line items remain the same and what gets updated. For Example:

 

* Approval Status: If cloning from an Approved Quote then new quote created should have status set to 'Ready'
* Start Date, Service Activate Date: To be set to Today for new cloned quote created
* Valid Until Date: To be set to today + 30 days for new cloned quote
* If Primary: do not make new cloned quote primary

Could you please clarify on whether these requirements can be met by customization? If yes, could you please provide more details on the same.



If you found my answer helpful, please give me a kudo ↑
Help others find answers faster by accepting my post as a solution √

1 REPLY
Support SME

Re: Question on Clone Quote

Solution:

 

Some pointers:

 

1) You can use the "Quote.cloneQuote()" method on the Quote class described here:
https://knowledgecenter.zuora.com/CA_Commerce/I_Development_Resources/C_Component_Library/C_Global_C...

 

After the cloning is completed, you would override whatever fields you want on the new cloned quote. Note that you are only able to copy products for a New Subscription Quote, and this is an all-or-nothing copy. You can leverage additional methods to add/remove products after the clone process as you see fit.

 

Sample code:
//Load an existing quote
zqu.Quote existingQuote = zqu.Quote.getInstance(quoteId);

//populate the clone options
zqu.CloneQuoteOptions options = new zqu.CloneQuoteOptions();
options.shouldCloneProducts = true;

//clone the quote
zqu.QuoteCloneResponse cloneResponse = existingQuote.cloneQuote(options);

//save the cloned quote

if (cloneResponse.isSuccess) {
zqu.Quote clonedQuote = cloneResponse.clonedQuote;
clonedQuote.set('QuoteStatus__c','Draft');
clonedQuote.set('zqu__Primary__c',false);

//Save changes to new quote
clonedQuote.buildAndSave();
}

 



If you found my answer helpful, please give me a kudo ↑
Help others find answers faster by accepting my post as a solution √