AsyncQuoteSubmit Class
This article describes the AsyncQuoteSubmit class, its global methods, and the related classes. The AsyncQuoteSubmit and the related classes are designed to submit large quotes with asynchronous requests. To use these classes, you must enable high volume subscription support for your Zuora tenant.
You must follow the sequence of AsyncQuoteSubmit API calls to preview or submit a Quote. See the diagram of AsyncQuoteSubmit API Call Sequence for details.
AsyncQuoteSubmit Global Methods
The AsyncQuoteSubmit class includes the following global methods.
Method | Type | Description |
---|---|---|
initialize(InitializationSettings initializationSettings) |
InitializationResponse |
Initializes Subscription Header level information. Throws ZQException if the Quote already contains Asynchronous Draft Order information. |
addActions(AddActionsSettings addActionsSettings) |
AddActionsResponse |
Adds Amendments to the Subscription. Throws ZQException if Asynchronous Draft Order information is missing. |
preview(PreviewSettings previewSettings) |
PreviewResponse |
Kicks off a preview process for the Draft. Throws ZQException if Asynchronous Draft Order information is missing. |
previewResult(PreviewResultSettings previewResultSettings) |
PreviewResultResponse |
Checks whether the preview process has finished. Once completed, retrieves the aggregate Invoice-level total. Throws ZQException if Asynchronous Draft Order information is missing. |
previewInvoiceItems(PreviewMetricSettings previewMetricSettings) |
PreviewInvoiceItemsResponse |
Returns the previewed InvoiceItems from the PreviewResult based on the configurations specified in PreviewMetricSettings. Throws ZQException if Asynchronous Draft Order information is missing. |
previewCharges(PreviewMetricSettings previewMetricSettings) |
PreviewChargesResponse |
Returns the previewed Charges from the PreviewResult based on the configurations specified in PreviewMetricSettings. Throws ZQException if Asynchronous Draft Order information is missing. |
activate(ActivateSettings activateSettings) |
ActivateResponse |
Submits the draft subscription for activation. Throws ZQException if Asynchronous Draft Order information is missing. |
getActivationStatus(ActivationStatusSettings activationStatusSettings) |
ActivationStatusResponse |
Checks for the current status of an activation. Returns Subscription system information upon completion. |
AsyncQuoteSubmit.InitializeSettings Class
AsyncQuoteSubmit.InitializeSettings Class Properties
The AsyncQuoteSubmit.InitializeSettings class includes the following global properties.
Property | Type | Description |
---|---|---|
quoteId | Id |
The Id of the Quote that the Draft Order is based on. |
AsyncQuoteSubmit.InitializeResponse Class Properties
The AsyncQuoteSubmit.InitializeResponse class includes the following global properties.
Property | Type | Description |
---|---|---|
orderId | String | Zuora Id of the created Draft Order. The same Zuora Order Id can also be found in the AsyncDraftOrderId__c field of the Quote once the response is received. |
subscriptionId | String | Zuora Id of the created subscription. The same Zuora Subscription Id can also be found in the AsyncDraftSubscriptionId__c field of the Quote once the response is received. |
AsyncQuoteSubmit.AddActionsSettings Class
The AsyncQuoteSubmit.AddActionsSettings class includes the following global properties.
Property | Type | Description |
---|---|---|
quoteId | Id | The Id of the Quote that the Draft Order is based on. |
amendmentIds | List<Id> | The Id List of the QuoteAmendments that should be added to the draft Order. |
isPreview | Boolean |
If this property is set to If this property is set to The default value is |
AsyncQuoteSubmit.AddActionsResponse Class
The AsyncQuoteSubmit.AddActionsResponse class includes no global properties.
AsyncQuoteSubmit.AddActionsException Class
The AsyncQuoteSubmit.AddActionsException class includes the following global methods.
Method | Type | Description |
---|---|---|
getErrorQuoteAmendmentIds() | List<Id> | Returns a list of the QuoteAmendment Ids that have not been successfully added to the Draft Order. |
setErrorQuoteAmendmentIds() | void | Sets the list of the QuoteAmendment Ids that have not been successfully added to the Draft Order. Should only be used for unit testing. |
AsyncQuoteSubmit.PreviewSettings Class
The AsyncQuoteSubmit.PreviewSettings class includes the following global properties.
Property | Type | Description |
---|---|---|
quoteId | Id | The Id of the Quote that the Draft Order is based on. |
AsyncQuoteSubmit.PreviewResponse Class
The AsyncQuoteSubmit.PreviewResponse class includes the following global properties.
Property | Type | Description |
---|---|---|
jobId |
String |
Zuora Id of the created preview job. Used to retrieve the preview result. The same jobId can also be found in the AsyncJobId__c field of the Quote once the response is received. |
AsyncQuoteSubmit.PreviewResultSettings Class
The AsyncQuoteSubmit.PreviewResultSettings class includes the following global properties.
Property | Type | Description |
---|---|---|
quoteId | Id |
The Id of a quote that is being or has been previewed. |
AsyncQuoteSubmit.PreviewResultResponse Class
The AsyncQuoteSubmit.PreviewResponse class includes the following global properties.
Property | Type | Description |
---|---|---|
status |
String |
Status of the preview process. Possible values are 'Initialized', 'Processing', 'Completed', and 'Failed'. When the status is 'Completed', the MetricResult.PreviewResult attribute will be populated with the result. |
result |
MetricResult.PreviewResult |
Includes a list of MetricResult.Invoice and a list of MetricResult.ChargeMetric. Only Invoice-header level information will be populated in this response. For more granular preview results, see PreviewInvoiceItemsResponse and PreviewChargesResponse. |
AsyncQuoteSubmit.PreviewMetricsSettings Class
The AsyncQuoteSubmit.PreviewMetricsSettings class includes the following global properties.
Property | Type | Description |
---|---|---|
quoteId |
Id |
The Id of the quote that has been previewed. |
pageSize |
Integer |
The maximal number of records to be retrieved. |
offset |
Integer |
The offset of the records to be retrieved. |
AsyncQuoteSubmit.PreviewInvoiceItemsResponse Class
The AsyncQuoteSubmit.PreviewInvoiceItemsResponse class includes the following global properties.
Property | Type | Description |
---|---|---|
count |
Integer |
The number of records in this response. Less than or equal to the specified pageSize in the PreviewMetricsSettings reference. |
hasMore |
Boolean |
Indicates whether there are more records to be retrieved. |
metric |
MetricResult.InvoiceItems |
A list of MetricResult.InvoiceItem objects in the previewed draft order. |
AsyncQuoteSubmit.PreviewChargesResponse Class
The AsyncQuoteSubmit.PreviewChargesResponse class includes the following global properties.
Property | Type | Description |
---|---|---|
count |
Integer |
The number of records in this response. Less than or equal to the specified pageSize in the PreviewMetricsSettings reference. |
hasMore |
Boolean |
Indicates whether there are more records to be retrieved. |
metric |
MetricResult.Charges |
A list of MetricResult.Charges objects in the previewed draft order. |
AsyncQuoteSubmit.ActivateSettings Class
The AsyncQuoteSubmit.ActivateSettings class includes the following global properties.
Property | Type | Description |
---|---|---|
quoteId |
Id |
The Id of the Quote that the Draft Order is based on. |
AsyncQuoteSubmit.ActivateResponse Class
The AsyncQuoteSubmit.ActivateResponse class includes no global properties.
AsyncQuoteSubmit.SubmissionStatusSettings Class
The AsyncQuoteSubmit.SubmissionStatusSettings class includes the following global properties.
Property | Type | Description |
---|---|---|
quoteId | Id |
The Id of a quote that is being or has been activated. |
AsyncQuoteSubmit.SubmissionStatusResponse Class
The AsyncQuoteSubmit.SubmissionStatusResponse class includes the following global properties.
Property | Type | Description |
---|---|---|
status |
String |
Status of the activation process. Possible values are 'Initialized', 'Processing', 'Completed', and 'Failed'. When the status is 'Completed', the MetricResult.ActivationResult attribute will be populated with the result. |
result |
MetricResult.ActivationResult |
The result of the activated order. Includes the Order Header information, a List of Subscription data, and a list of InvoiceNumbers. |
Sample Code
Initialize a Draft Order for a Quote
public void initializeHighVolumeQuote(Id highVolumeQuoteId) { zqu.AsyncQuoteSubmit.InitializationSettings initializationSettings = new zqu.AsyncQuoteSubmit.InitializationSettings(); initializationSettings.quoteId = highVolumeQuoteId; zqu.AsyncQuoteSubmit.InitializationResponse initializationResponse = zqu.AsyncQuoteSubmit.initialize(initializationSettings); zqu__Quote__c highVolumeQuote = [ SELECT Id, zqu__AsyncDraftOrderId__c, zqu__AsyncDraftSubscriptionId__c FROM zqu__Quote__c WHERE Id = :highVolumeQuoteId LIMIT 1 ]; System.assertEquals(initializationResponse.orderId, highVolumeQuote.zqu__AsyncDraftOrderId__c); System.assertEquals(initializationResponse.subscriptionId, highVolumeQuote.zqu__AsyncDraftSubscriptionId__c); }
Add Actions to an Initialized Draft Order
public void addActions(Id highVolumeQuoteId, Set<Id> quoteAmendmentIds) { zqu.AsyncQuoteSubmit.AddActionsSettings addActionsSettings = new zqu.AsyncQuoteSubmit.AddActionsSettings(); addActionsSettings.quoteId = highVolumeQuoteId; addActionsSettings.quoteAmendmentIds = quoteAmendmentIds; try { zqu.AsyncQuoteSubmit.AddActionsResponse addActionsResponse = zqu.AsyncQuoteSubmit.addActions(addActionsSettings); } catch (zqu.AsyncQuoteSubmit.AddActionsException addActionsException) { System.debug('Failed with message: ' + addActionsException.getMessage()); System.debug('Failed to add Quote Amendment Id values: ' + addActionsException.getErrorQuoteAmendmentIds()); } }
Initialize a Preview for a Draft Order after Actions have been Added
public void initializePreview(Id highVolumeQuoteId) { zqu.AsyncQuoteSubmit.PreviewSettings previewSettings = new zqu.AsyncQuoteSubmit.PreviewSettings(); previewSettings.quoteId = highVolumeQuoteId; zqu.AsyncQuoteSubmit.PreviewResponse previewResponse = zqu.AsyncQuoteSubmit.preview(previewSettings); zqu__Quote__c highVolumeQuote = [ SELECT Id, zqu__AsyncJobId__c FROM zqu__Quote__c WHERE Id = :highVolumeQuoteId LIMIT 1 ]; System.assertEquals(previewResponse.jobId, highVolumeQuote.zqu__AsyncJobId__c); }
Retrieve Results for a Draft Order Where the Preview has been Initialized
// This method should be called from within a scheduled job, in order to have it re-run until process is complete public void retrievePreviewResults(Id highVolumeQuoteId) { zqu.AsyncQuoteSubmit.PreviewResultSettings previewResultSettings = new zqu.AsyncQuoteSubmit.PreviewResultSettings(); previewResultSettings.quoteId = highVolumeQuoteId; zqu.AsyncQuoteSubmit.PreviewResultResponse previewResultResponse = zqu.AsyncQuoteSubmit.previewResult(previewResultSettings); switch on previewResultResponse.status { when 'Initialized' { System.debug('Preview has been initialized.'); } when 'Processing' { System.debug('Preview is currently being processed.'); // If this is part of scheduled job, the job that calls this method should be rescheduled for a later time in order to check status again } when 'Failed' { System.debug('Process has failed.'); } when 'Completed' { System.debug('Process has completed'); // Check if there was an error if (previewResultResponse.errors != null) { System.debug(previewResultResponse.errors); } else { System.debug(previewResultResponse.result.invoices); System.debug(previewResultResponse.result.chargeMetrics); } } when else { System.debug('Process is in an unknown state'); } } }
Retrieve Preview Invoice Items for a Draft Order Where the Preview Job has Completed
// Retrieve Preview Invoice Items for completed preview job public void retrievePreviewInvoiceItems(Id highVolumeQuoteId) { // This is an example where 12 * 1000 = 12,000 Invoice Items are expected zqu.AsyncQuoteSubmit.PreviewMetricsSettings previewMetricsSettings = new zqu.AsyncQuoteSubmit.PreviewMetricsSettings(); previewMetricsSettings.quoteId = highVolumeQuoteId; // Skip records 0 - 999 (zero-based index) previewMetricsSettings.offset = 1000; // Retrieve records 1000 - 1999 (zero-based index) previewMetricsSettings.pageSize = 1000; zqu.AsyncQuoteSubmit.PreviewInvoiceItemsResponse previewInvoiceItemsResponse = zqu.AsyncQuoteSubmit.previewInvoiceItems(previewMetricsSettings); System.assertEquals(previewMetricsSettings.pageSize, previewInvoiceItemsResponse.count); // Should be true, since there are more records to go through System.assertEquals(true, previewInvoiceItemsResponse.hasMore); for (zqu.MetricsResult.InvoiceItem invoiceItem : previewInvoiceItemsResponse.metrics) { System.debug(invoiceItem); } }
Retrieve Preview Charges for a Draft Order Where the Preview Job has Completed
// Retrieve Preview Charges for completed preview job public void retrievePreviewCharges(Id highVolumeQuoteId) { // This is an example where 1000 charges exist under the quote zqu.AsyncQuoteSubmit.PreviewMetricsSettings previewMetricsSettings = new zqu.AsyncQuoteSubmit.PreviewMetricsSettings(); previewMetricsSettings.quoteId = highVolumeQuoteId; // Skip records 0 - 249 (zero-based index) previewMetricsSettings.offset = 250; // Retrieve records 250 - 499 (zero-based index) previewMetricsSettings.pageSize = 250; zqu.AsyncQuoteSubmit.PreviewChargesResponse previewChargesResponse = zqu.AsyncQuoteSubmit.previewCharges(previewMetricsSettings); System.assertEquals(previewMetricsSettings.pageSize, previewChargesResponse.count); // Should be true, since there are more records to go through System.assertEquals(true, previewChargesResponse.hasMore); for (zqu.MetricsResult.Charge charge : previewChargesResponse.metrics) { System.debug(charge); } }
Activate the Draft Order
public void activateDraftOrder(Id highVolumeQuoteId) { zqu.AsyncQuoteSubmit.ActivateSettings activateSettings = new zqu.AsyncQuoteSubmit.ActivateSettings(); activateSettings.quoteId = highVolumeQuoteId; zqu.AsyncQuoteSubmit.ActivateResponse activateResponse = zqu.AsyncQuoteSubmit.activate(activateSettings); }
Retrieve activation results
// This method should be called from within a scheduled job, in order to have it re-run until process is complete public void retrieveActivationResults(Id highVolumeQuoteId) { zqu.AsyncQuoteSubmit.ActivateResultSettings activateResultSettings = new zqu.AsyncQuoteSubmit.ActivateResultSettings(); activateResultSettings.quoteId = highVolumeQuoteId; zqu.AsyncQuoteSubmit.ActivateResultResponse activateResultResponse = zqu.AsyncQuoteSubmit.activateResult(activateResultSettings); switch on activateResultResponse.status { when 'Initialized' { System.debug('Preview has been initialized.'); } when 'Processing' { System.debug('Preview is currently being processed.'); // If this is part of scheduled job, the job that calls this method should be rescheduled for a later time in order to check status again } when 'Failed' { System.debug('Process has failed.'); } when 'Completed' { System.debug('Process has completed'); if (activateResultResponse.errors != null) { System.debug(activateResultResponse.errors); } else { System.debug(activateResultResponse.result); } } when else { System.debug('Process is in an unknown state'); } } }