Populate Quote and Charge Metrics in Custom Code
If you use custom code in your quoting flow and do not use the out-of-the-box Quote Detail page, you need to add the code to explicitly retrieve and populate the quote and charge metrics as below:
- Make a call to the zqu.zQuoteUtil.PreviewQuotes method to get the quote and charge metrics from Zuora.
- Assign the quote level metrics to the corresponding fields on the zqu__Quote__c. The fields are mapped as below:
-
zqu.zQuoteUtil.zBillingResult.totalMrr -> zqu__Quote__c. zqu__Previewed_MRR__c
-
zqu.zQuoteUtil.zBillingResult.totalTcv -> zqu__Quote__c. zqu__Previewed_TCV__c
-
zqu.zQuoteUtil.zBillingResult.totalInfo.total -> zqu__Quote__c.zqu__Previewed_Total__c
-
zqu.zQuoteUtil.zBillingResult.totalInfo.subtotal -> zqu__Quote__c.zqu__Previewed_SubTotal__c
-
zqu.zQuoteUtil.zBillingResult.totalInfo.tax -> zqu__Quote__c.zqu__Previewed_Tax__c
-
zqu.zQuoteUtil.zBillingResult.totalInfo.discount -> zqu__Quote__c.zqu__Previewed_Discount__c
-
- Assign the charge level metrics values to the corresponding fields on the zqu__QuoteRatePlanCharge__c objects. The fields are mapped as below:
-
zqu.zQuoteUtil.ChargeMetrics.discount -> zqu__QuoteRatePlanCharge__c.zqu__BillingDiscount__c
-
zqu.zQuoteUtil.ChargeMetrics.tax -> zqu__QuoteRatePlanCharge__c.zqu__BillingTax__c
-
zqu.zQuoteUtil.ChargeMetrics.total -> zqu__QuoteRatePlanCharge__c.zqu__BillingTotal__c
-
zqu.zQuoteUtil.ChargeMetrics.subtotal -> zqu__QuoteRatePlanCharge__c.zqu__BillingSubtotal__c
-
zqu.zQuoteUtil.ChargeMetrics.mrr -> zqu__QuoteRatePlanCharge__c.zqu__PreviewedMrr__c (for new subscriptions)
-
zqu.zQuoteUtil.ChargeMetrics.deltaMrr -> zqu__QuoteRatePlanCharge__c.zqu__PreviewedMrr__c (for amendment/renewals)
-
zqu.zQuoteUtil.ChargeMetrics.tcv -> zqu__QuoteRatePlanCharge__c.zqu__PreviewedTcv__c (for new subscriptions)
-
zqu.zQuoteUtil.ChargeMetrics.deltaTcv -> zqu__QuoteRatePlanCharge__c.zqu__PreviewedTcv__c (for amendment/renewals)
-
- To display the quote metrics, add the zqu__Quote_Detail_Metrics field set on the zqu__Quote__c object to your custom quote page.
- To display the charge metrics, add the below fields to the zqu__DisplayChargeFields field set on the zqu__QuoteRatePlanCharge__c object:
- zqu__PreviewedTCV__c
- zqu__PreviewedMRR__c
- Add the zqu__DisplayChargeFields field set to your custom product selector page.
Below is an example code segment that retrieves quote metrics:
List<zqu.zQuoteUtil.zBillingResult> billingResults = zqu.zQuoteUtil.PreviewQuotes(quoteIdList); for(zqu.zQuoteUtil.zBillingResult billingResult : billingResults) { if (billingResult.success == false) { return quote; } // The PreviewQuotes method returns the metrics, // and you need to manually update the quote. quote.zqu__Previewed_MRR__c = billingResult.totalMrr; quote.zqu__Previewed_TCV__c = billingResult.totalTcv; if (billingResult.totalInfo != null){ quote.zqu__Previewed_Discount__c = billingResult.totalInfo.discount; quote.zqu__Previewed_SubTotal__c = billingResult.totalInfo.subTotal; quote.zqu__Previewed_Tax__c = billingResult.totalInfo.tax; quote.zqu__Previewed_Total__c = billingResult.totalInfo.total; } }