Happy Business Starts Here

Highlighted
Zuora Support

How to Programatically create amendment quote.

Question:  How to Programatically create amendment quote.

Could you provide sample code. 






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 1
Zuora Support

Re: How to Programatically create amendment quote.

Answer:

 

Below is the same code to create amendment quote

//Create a new Quote
zqu__Quote__c quoteSObject = new zqu__Quote__c();
quoteSObject.zqu__SubscriptionType__c = 'Amend Subscription';
quoteSObject.zqu__ZuoraAccountId__c =
   ApexPages.currentPage().getParameters().get('existingAccountId');
quoteSObject.zqu__ExistSubscriptionId__c =
   ApexPages.currentPage().getParameters().get('existingSubscriptionId');
   
zqu.Quote amendmentQuote = zqu.Quote.createNewInstance(quoteSObject);
  
// Quote and Quote Charge Details inserted to database here
amendmentQuote.buildAndSave();
  
 //Add products to the Quote
List<zqu.Product> productsToAdd = zqu.Product.loadProductsWithChildren(new List<Id>{'product1Id', 'product2Id'});
List<zqu.QuoteProduct> addedProducts = amendmentQuote.addQuoteProducts(productsToAdd);
  
// Creates/updates/deletes Quote Charge Detail records
// based on changes made to the Quote Products
amendmentQuote.save();

Also please find below KC article which has many examples.

https://knowledgecenter.zuora.com/CA_Commerce/I_Development_Resources/C_Component_Library/C_Global_C...






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