zQuoteUtil Class
The zQuoteUtil class provides a variety of global methods, listed in the table below.
A number of the methods provides the bulk API version for you to save the API limits in Salesforce. For example, if you are adding several charge groups to a quote, use the addChargeGroups
method instead of addChargeGroup
.
zQuoteUtil Global Methods
As of the Winter '14 Release of Salesforce, limits can vary based on CPU usage. See this Salesforce article for more information.
The zQuoteUtil class includes the following global methods.
Method Signature | Description | ||||||
---|---|---|---|---|---|---|---|
static zChargeGroup addChargeGroup |
Use this method to add a charge group to an existing quote. | ||||||
static LIST addChargeGroups (LIST chargeGroups) |
Use this method to add up to 30 charge groups to a quote in a single call. Zuora recommends that you use an average of 10 charges per group. In a call to addChargeGroups() with a list of 30 groups, there should be no more than 300 charges total across all charge groups. This method was added in Zuora Quotes version 5.6. |
||||||
static LIST calculateChargesOnDiscountChange (LIST charges) |
Calculates EffectivePrice and Total for the selected charge list within a quote when only the discount is changed. | ||||||
static LIST calculateChargesOnEffectivePriceChange (LIST charges) |
Calculates Discount and Total for the selected charge list within a quote when only the Effective Price is changed. | ||||||
static LIST calculateChargesOnQuantityChange (LIST charges) |
Calculate sEffectivePrice and Total for the selected charge list within a quote when only the Quantity is changed. | ||||||
static LIST calculateChargesOnTotalChange (LIST charges) |
Calculates Discount and EffectivePrice for the selected charge list within a quote when only the Total Price is changed. | ||||||
static void changeInvoiceOwner (String quoteId, Id billingAccountId) |
Use this method to trigger an invoice owner change on Amendments and Renewals. | ||||||
static SOBJECT:Quote__c createCancellationAmendment (Id quoteId) |
Cancels a subscription. This method creates a QuoteAmendment__c record of type Cancellation and links it to the quote. Use this with the sendToZBilling method to cancel a subscription. See sendToZBilling Method for more information. |
||||||
static zChargeGroup deleteChargeGroup (zChargeGroup deleteChargeGroup) |
Deletes a charge group in an existing quote. The quote type can be New Subscription, Amendment, or Renewal. |
||||||
static LIST deleteChargeGroups (LIST deleteChargeGroups) |
Deletes one or more charge groups in an existing quote. The quote type can be New Subscription, Amendment, or Renewal. Use this method to delete up to 30 charge groups from a quote in a single call. Zuora recommends that you have no more than an average of 10 charges per group. This means that in a call to See Example Code for using this method. This method is available in the Versions 5.9 and later of Zuora Quotes. |
||||||
static zChargeGroup getChargeGroup (Id quoteID, Id ratePlanID) |
Gets the charge group by a ratePlanID and the quoteID. The charge group type is always TYPE_PRODUCT_NEW. |
||||||
static zChargeGroup getChargeGroup (Id quoteID, Id ratePlanID, Boolean withExpired) |
Gets the charge group identified by the ratePlanID that belongs to a quote identified by the quoteID. | ||||||
static LIST getChargeGroups (String quoteID) |
Gets all existing charge groups of a quote identified by the quoteID, for all types of quotes, including New Subscription, Amendment or Renewal. For Amendment quotes, with Orders enabled, this method will return all segments of a charge group. This global method supports quotes with up to 300 quote charges. For the Orders feature, we are actively soliciting feedback from a small set of early adopters. If you wish to have access to the feature, submit a request at Zuora Global Support. |
||||||
static LIST getChargeGroups (String quoteId, LIST ratePlanIdList) |
Loads a list of product rate plans and associates them with an existing quote. You can use this global method to load up to 500 product rate plan charges. See Loading a List of Product Rate Plans into a Quote for an example of using this method. This method was added in Zuora Quotes version 5.8. |
||||||
Static Map getEntityConfigInformation |
Returns all configuration settings for a specific entity. | ||||||
static ApexPages.StandardSetController |
Gets the setController for ZSelectTable component to use as the data provider for product selection. | ||||||
static LIST getRatePlanIds (String productId, String zCurrency, Date zQuoteStartDate) |
Gets a rate plan ID list with the input of currency and quote start date. This can be used with the ZSelectTable component. | ||||||
static ApexPages.StandardSetController getRatePlanSetController (LISTratePlanIDs, LIST fieldNames, Integer pageSize) |
Gets the setController for ZSelectTable component to use as the data provider for a rate plan selection. | ||||||
static LIST getZProductIds (String zCurrency, Date zQuoteStartDate) |
Gets a product ID list with the input of currency and quote start date. This can be used with the ZSelectTable component. | ||||||
static MAP getZuoraConfigInformation() |
Returns all fields and values in the Zuora Quotes configuration, Zuora_Config__c, in a map that holds key-value pairs, field names as keys and field values as values. |
||||||
static LIST previewQuotes (LIST quoteIds) |
Previews Quote Metrics from the Zuora application that calculates quote metrics through the end of the subscription term. The quoteIds input parameter are the Salesforce IDs of the quotes you want to preview. The method returns a list of ZBillingResults where each ZBillingResult contains the metrics for one quote. See below for the call limits. This method is available as of Zuora Quotes version 6.0. |
||||||
static LIST previewQuotes (LIST quoteIds, Integer numOfPeriods) |
Previews Quote Metrics from the Zuora application that calculates quote metrics based on the specified number of billing periods. The quoteIds input parameter are the Salesforce IDs of the quotes you want to preview. The numberOfPeriods input parameter is the number of billing periods used to calculate the quote metrics. If NULL, quote metrics are calculated through then end of the subscription term. The method returns a list of ZBillingResults where each ZBillingResult contains the metrics for one quote. See below for the call limits. This method is available as of Zuora Quotes version 6.0. |
||||||
static SOBJECT:Quote__c renewQuote |
Creates a renewal amendment on an existing quote that was created for an original subscription. | ||||||
static LIST sendToZBilling |
Collects, validates, and sends one or more quotes to Z-Billing. This method was added in Zuora Quotes version 5.6, and replaces the previous version of the sendToZBilling method. See sendToZBilling Method for detailed information about using this method. |
||||||
static void setSubscriptionTermChanges (MAP< String, Map< String, Object > >subscriptionTermChanges) |
Updates the subscription terms. | ||||||
static void storeExistingProducts |
Retrieves the original subscription rate plans charges from Zuora and stores the data in Salesforce for amendment and renewal quotes. |
||||||
static zChargeGroup updateChargeGroup (zChargeGroup updateChargeGroup) |
Updates the given charge group. | ||||||
static LIST updateChargeGroups (LIST updateChargeGroups) |
Updates one or more charge groups for a quote. The quote type can be New Subscription, Amendment, or Renewal. Use this method to update up to 30 charge groups belonging to a quote in a single call. Zuora recommends that you have no more than an average of 10 charges per group. In a call to See Example Code for using this method. This method is available in the Versions 5.9 and later of Zuora Quotes. |
||||||
static void updateZChargeGroupFromSObject (zqu.zChargeGroup zcg, List sobjects, Map> changedFields, String namespace) |
Updates the ZChargeGroup with the values from the ChargeProxy__c object fields. ZChargeGroup represents the rate plans. |
||||||
static updateQuoteStartDate |
Updates Quote Start Date and aligns product actions with it. Parameters:
Sample Code:
The following are the date fields that are updated by this global method:
|
previewQuotes Call Limits
If there are less than 30 subscription and amendments, the previewQuotes process will be executed synchronously.
If there are between 30 - 200 subscriptions and amendments, the request will be sent synchronously, but any further write backs/data updates will be asynchronous.
Anything between 200-400 will be batched into future methods in batches of 200.
Up to 400 quote ids can be passed to the previewQuotes call.
Example Code
The following is an example code for the deleteChargeGroups method:
// Delete the selected charge groups String quoteId = 'a0Fd000000FfDxl'; List<zqu.zChargeGroup> chargeGroups = zqu.zQuoteUtil.getChargeGroups(quoteId); List<zqu.zChargeGroup> chargeGroupsToDelete; for (zqu.zChargeGroup chargeGroup : chargeGroups) { if ( chargeGroup.ratePlanName == 'Basic Plan') { chargeGroupsToDelete.add(chargeGroup); } } zqu.zQuoteUtil.deleteChargeGroups(chargeGroupsToDelete);
The following is an example code for the updateChargeGroups method:
// Load the charge groups with rate plan name "Basic Plan" that need to be updated String quoteId = 'a0Fd000000FfDxl'; List<zqu.zChargeGroup> chargeGroups = zqu.zQuoteUtil.getChargeGroups(quoteId); List<zqu.zChargeGroup> chargeGroupsToUpdate = new List<zqu.zChargeGroup>(); for (zqu.zChargeGroup chargeGroup : chargeGroups) { if ( chargeGroup.ratePlanName == 'Basic Plan') { chargeGroupsToUpdate.add(chargeGroup); } } // Update the discount amount of all charges in the charge groups and recalculate the charges for( zqu.zChargeGroup group : chargeGroupsToUpdate ) { for ( zqu.zCharge charge : group.zCharges ) { charge.discount = '10'; } } // Persist the updates chargeGroupsToUpdate = zqu.zQuoteUtil.updateChargeGroups(chargeGroupsToUpdate); System.debug('debug: charge group = ' + chargeGroupsToUpdate);
The following is an example code for updating charges for weekly billing.
List<zqu.zChargeGroup> zcgs = zqu.ZQuoteUtil.getChargeGroups('a0Uo0000007uEiy'); for (zqu.zChargeGroup zcg : zcgs){ if(zcg.groupType == zqu.zChargeGroup.TYPE_SUBSCRIPTION_ADDED || zcg.groupType == zqu.zChargeGroup.TYPE_AMENDMENT_NEWPRODUCT || zcg.groupType == zqu.zChargeGroup.TYPE_RENEWAL_NEWPRODUCT){ for(zqu.zCharge zc : zcg.zCharges){ if(zc.MODEL == 'Flat Fee Pricing'){ zc.PERIOD = 'Week'; zc.BILL_CYCLE_TYPE = 'SpecificDayofWeek'; zc.WEEKLY_BILL_CYCLE_DAY = 'Tuesday'; } else if(zc.MODEL == 'Volume Pricing'){ zc.PERIOD = 'Specific Weeks'; zc.SPECIFIC_BILLING_PERIOD = '5'; zc.BILL_CYCLE_TYPE = 'SpecificDayofWeek'; zc.WEEKLY_BILL_CYCLE_DAY = 'Saturday'; } if(zc.CHARGE_TYPE == 'Recurring'){ zc.PERIOD = 'Week'; zc.BILL_CYCLE_TYPE = 'SpecificDayofWeek'; zc.WEEKLY_BILL_CYCLE_DAY = 'Tuesday'; zc.LIST_PRICE_BASE = 'Per Week'; } } } }