Happy Business Starts Here

API to add a product to Zuora-Quote

Highlighted
Valued Scholar

API to add a product to Zuora-Quote

Hey I am new to Zuora. Please help me with this. What is the API to add a product to Zuora-Quote?

8 REPLIES 8
Highlighted
Community Manager

Re: API to add a product to Zuora-Quote

Hi @pankaj,

 

Welcome to Zuora!

 

Have you had a chance to check out our new Developer Center where there are code libraries and API references? See this article for more information about the Developer Center.

 

Lana


Lana Lee | Senior Community Manager and Strategist
"A little consideration, a little thought for others, makes all the difference." —A. A. Milne
Highlighted
Zuora Alumni

Re: API to add a product to Zuora-Quote

I believe he is asking about Global Methods in Quotes not the new REST APIs.

Highlighted
Zuora Alumni

Re: API to add a product to Zuora-Quote

Hi Pankaj,

 

Are you looking for the Global methods to  Add, Update, and Delete Charges?

If so, please review the following Article in our Knowledge Center that documents all the Global methods that you can use to perform this task

 

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

 

This article has also included sample code that you can use as a reference.

 

For your specific requirement to add product to a Quote, you can use 

Global Method: addChargeGroup (zChargeGroup)

 

Please review and let us know if you have any question

 

Thank you
Doyeli






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

Highlighted
Valued Scholar

Re: API to add a product to Zuora-Quote

yes @nathanc

 

When I tried using this code snipped 

 

zqu.Quote existingQuote = zqu.Quote.getInstance('quoteId');
System.debug(existingQuote);
List<product2> productList = [select id from product2 where id='productId'];
existingQuote.addQuoteProducts(productList);

 

it's throwing me error
Method does not exist or incorrect signature: [zqu.Quote].addQuoteProducts(List<Product2>)

 

My Z-quote version is 7.32

Highlighted
Zuora Alumni

Re: API to add a product to Zuora-Quote

Hi Pankaj,

 

I understand you came to know about addQuoteProducts method from  the following Article:

 

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

 

If you review this article, it is mentioned:

"This article describes the Quote class, its global methods, and related classes. Use the classes and global methods to programmatically implement bundling."

 

So, looks like these nethods are used to programmatically implement bundling.

 

You will then need to review the following Article as well (This article describes the Product class, its global methods, and the related classes. Use these classes and global methods to programmatically implement Bundling and Guided Selling.)

 

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

 

The following code worked on my end (I am on ZQUote 7.43):

 

zqu.Quote existingQuote = zqu.Quote.getInstance('a16410000002fFI');
System.debug(existingQuote);
zqu.Product p = zqu.Product.loadProduct('01t41000001AAbe');
System.debug(p);
List<zqu.Product> products = new List<zqu.Product>();
products.add(p);
existingQuote.addQuoteProducts(products);
existingQuote.save();

 

Can you please test and let me know how it goes

 

Thank you

Doyeli






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

Highlighted
Valued Scholar

Re: API to add a product to Zuora-Quote

Thanks for the help @doyeli.

 

This code is snippet is throwing an error from my developer console.

zqu.Quote existingQuote = zqu.Quote.getInstance('a16410000002fFI');
System.debug(existingQuote);
zqu.Product p = zqu.Product.loadProduct('01t41000001AAbe');
System.debug(p);
List<zqu.Product> products = new List<zqu.Product>();
products.add(p);
existingQuote.addQuoteProducts(products);
existingQuote.save();

 

Eror - 

'Line: 245, Column: 1
System.NullPointerException: Attempt to de-reference a null object'

 

But, I am able to add product  to a quote using this code snippet

 

zqu.ZChargeGroup chargeGroup = zqu.zQuoteUtil.getChargeGroup('quoteId', 'productRatePlanId');
System.debug(chargeGroup);
zqu.ZQuoteUtil.addChargeGroup(chargeGroup);

 

Have a great day ahead !!

Highlighted
Zuora Alumni

Re: API to add a product to Zuora-Quote

Thank you Pankaj.

If you would like me to review the error message that is being thrown from the first code snippet, I will need login access to your salesforce Org.

I am going to send you a private Message to discuss the next step.

 

Thank you
Doyeli






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

Highlighted
Newly Enrolled

Re: API to add a product to Zuora-Quote

Hi Guys,

 

I am facing issue while using this function call to create a new Quote instance from saved Zquote object.

zqu__Quote__c zQuote.

zqu.Quote newquote = zqu.Quote.getInstance(zQuote.id);

but getting this exception

The callout was unsuccessful after 4 attempts: Callout from triggers are currently not supported

 I am using same function at some other place and it is working absolutely fine, i have no clue why this is creating issue , it is working fine with Async call (@future), but i dont want this, please let me know if you have any clue on this.

 

Regards

Manish