Happy Business Starts Here

Guru

Re: Need Quote Metrics populated

Adding your comments from the notification email:

 

Thanks for your reply, @MaggieL, but no. It doesn`t calculate anything. 

There is some additional info, maybe I`m doing something wrong.

 That`s how I add a product.

 

zqu.ZChargeGroup chargeGroup2 = zqu.zQuoteUtil.getChargeGroup(qte.Id, product2.Id); for ( zqu.zCharge charge1 : chargeGroup2.zCharges ) { charge1.QUANTITY = product2Quantity; } zqu.zQuoteUtil.calculateChargesOnQuantityChange(chargeGroup2.zCharges); chargeGroupsToAdd.add(chargeGroup2); zqu.ZQuoteUtil.addChargeGroups(chargeGroupsToAdd);

 

Same for product 1. After that, I can see that quantity changed for product 2 but totals are empty.

 

Next one step is 

 

zqu.zQuoteUtil.ZBillingResult previewResult = zqu.QuoteRecalculateController.JR_recalculate(qte.Id); System.debug(previewResult);

 

Dubug log

 

09:21:35:337 USER_DEBUG [143]|DEBUG|ZBillingResult:[chargeMetrics=null, deltaDiscountMrr=0, deltaDiscountTcb=0, deltaDiscountTcv=0, deltaMrr=0, deltaTcb=0, deltaTcv=0, discountMrr=0, discountTcb=0, discountTcv=0, expectedDeltaDiscountTax=0, expectedDeltaTax=0, expectedDiscountTax=0, expectedTotalTax=0, message=QuoteToBillingValidator.getSubscriptionsByQuoteNumber: The ZOQL query for Subscriptions by Quote Number has failed.:zqu.zApi.zApiException:The callout was unsuccessful after 4 attempts : You have uncommitted work pending. Please commit or rollback before calling outSmiley Sadzqu) 09:21:31:000 USER_DEBUG , orderMetrics=null, sfdcQuoteId=null, success=false, totalInfo=null, totalMrr=0, totalTcb=0, totalTcv=0, zAccountId=null, zSubscriptionId=null]

 

If I understand correctly, it calls Zuora app and tries to get Subscription data, but a subscription is not created yet (my workflow).

Also, I tried to call '/subscriptions/preview' but it gives me only MRR value so I can`t set totals manually.

 

After calling JR_recalculate() I get the error (see screenshot).

 

So, The problem is that when I create Quote and generate Quote document, total values are empty in PDF until I view the Quote page and regenerate PDF. That`s not acceptable to me. 

 

Maybe I miss something or there are some any ideas how I can get those values in APEX or REST API?

 Also, I tried to use zqu.Quote methods, zqu.zQuoteUtil.

 

Please, help me 

Maggie Longshore
Guru

Re: Need Quote Metrics populated

@rem Are you doing this for New Subscription Quotes?

 

I do this for renewal quotes.

 

 You have uncommitted work pending. Please commit or rollback before calling ou

 

This error indicates that you must callout in a thread without having saved any data.  This is a Salesforce rule. What I do is queue an async job to do the recalculation. Have you tried that?

 

 

Maggie Longshore
Tutor rem
Tutor

Re: Need Quote Metrics populated

@MaggieL I use it for New Subscription Quotes.

I tried to send a separate request from my app and call zqu.QuoteRecalculateController.JR_recalculate(). 

It works like a charm! 

Thank you a lot for helping me!