Skip to main content

Populate Quote and Charge Metrics in Custom Code


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:

  1. Make a call to the zqu.zQuoteUtil.PreviewQuotes method to get the quote and charge metrics from Zuora.
  2. 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__Quote__c.zqu__Previewed_Total__c

    • zqu.zQuoteUtil.zBillingResult.totalInfo.subtotal -> zqu__Quote__c.zqu__Previewed_SubTotal__c

    • -> zqu__Quote__c.zqu__Previewed_Tax__c

    • -> zqu__Quote__c.zqu__Previewed_Discount__c

  3. Assign the charge level metrics values to the corresponding fields on the zqu__QuoteRatePlanCharge__c objects. The fields are mapped as below:
    • -> zqu__QuoteRatePlanCharge__c.zqu__BillingDiscount__c

    • -> zqu__QuoteRatePlanCharge__c.zqu__BillingTax__c

    • -> 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)

  4. To display the quote metrics, add the zqu__Quote_Detail_Metrics field set on the zqu__Quote__c object to your custom quote page.
  5. 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
  6. 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 =
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 =;
        quote.zqu__Previewed_SubTotal__c = billingResult.totalInfo.subTotal;
        quote.zqu__Previewed_Tax__c =;
        quote.zqu__Previewed_Total__c =;