Creating Multiple Contracts from a Quote
This API creates one or more contracts (agreements) from a single quote by filtering the quote line items you want to include. Pass filter parameters along with the Quote ID to generate a contract containing only the matching line items. The quote or proposal must be associated with a price list.
You can use this API when you have a consolidated quote that includes products or services for multiple customers and you need to create separate contractual agreements for each customer. You can call the API multiple times on the same quote using different filter parameters to create multiple contracts, where each contract contains only the relevant subset of line items and maintains a relationship to the source quote.
Your original quote remains unchanged. Quote line items are not modified or deleted. Changes made to quote line items after contract creation are not synchronized to existing contract line items.
API
| API | createAgreementFromQuote |
| Package | Apttus_QPComply |
| Class | QPComplyWebService |
| Signature | webService static Apttus_QPComply.QPComplyWebService.CreateAgreementResponseDO createAgreementFromQuote(Apttus_QPComply.QPComplyWebService.CreateAgreementRequestDO request) |
Parameters
| Name | Type | Required? | Description |
|---|---|---|---|
request | Apttus_QPComply.QPComplyWebService.CreateAgreementRequestDO | Yes | The request data object that contains the Quote ID and the filter parameters. |
Request Data Object: Apttus_QPComply.QPComplyWebService.CreateAgreementRequestDO
| Field | Type | Description |
|---|---|---|
QuoteId | ID | The ID of the source quote or proposal from which you want to create the contract. |
LineNumbers | List<Integer> | The list of quote line item line numbers you want to include in the new contract. Only the matching line items are copied to the new cart and contract. |
FilterCriteria | List<Apttus_QPComply.QPComplyWebService.PropertyDO> | The list of filter properties (for example, customer or account identifier) used to identify the subset of quote line items to include in the contract. |
Properties | List<Apttus_QPComply.QPComplyWebService.PropertyDO> | The list of additional properties applicable to the contract creation process. |
Data Object: Apttus_QPComply.QPComplyWebService.PropertyDO
| Field | Type | Description |
|---|---|---|
Name | String | The name of the filter or property (for example, AccountId or CustomerId). |
Value | String | The value associated with the filter or property name. |
Response Data Object: Apttus_QPComply.QPComplyWebService.CreateAgreementResponseDO
| Field | Type | Description |
|---|---|---|
AgreementId | ID | The ID of the newly created Agreement (contract) object for the filtered line items. |
QuoteId | ID | The ID of the source quote from which the contract was created. |
Code Sample
The following sample shows how to create a contract from a quote by filtering specific line items. You can invoke this API multiple times on the same quote with different filter values to generate multiple contracts — one for each customer or filter combination.
/**
* The below method demonstrates how to create a contract from a quote
* by filtering specific line items (for example, by customer or account).
*/
public static void createContractFromQuote(String quoteNumber, List<Integer> lineNumbers, Id accountId)
{
List<Apttus_Proposal__Proposal__c> quote = [SELECT Id FROM
Apttus_Proposal__Proposal__c WHERE Name = :quoteNumber LIMIT 1];
if(!quote.isEmpty())
{
// Create the request object
Apttus_QPComply.QPComplyWebService.CreateAgreementRequestDO request =
new Apttus_QPComply.QPComplyWebService.CreateAgreementRequestDO();
// Set the source Quote ID
request.QuoteId = quote.get(0).Id;
// Specify the line numbers to include in the contract
request.LineNumbers = lineNumbers;
// Add filter criteria (for example, filter by Account ID)
List<Apttus_QPComply.QPComplyWebService.PropertyDO> filters =
new List<Apttus_QPComply.QPComplyWebService.PropertyDO>();
filters.add(new Apttus_QPComply.QPComplyWebService.PropertyDO(
'AccountId', accountId));
request.FilterCriteria = filters;
// Execute the createAgreementFromQuote routine
Apttus_QPComply.QPComplyWebService.CreateAgreementResponseDO response =
Apttus_QPComply.QPComplyWebService.createAgreementFromQuote(request);
System.debug('Contract has been successfully created. AgreementId = '
+ response.AgreementId);
}
}
Integration Details
API Prerequisites:
- The source quote (Proposal) must exist and must be associated with a price list.
- The quote must contain line items that match the filter criteria you provide.
- The standard Quote to Contract data mapping configuration must be in place. All existing field mappings continue to apply to both contract headers and contract line items.
- To receive asynchronous completion notifications, configure the
APTS_CPQAsyncNotifyCallbackClassadmin property with a class that implementsSystem.Callable.
Behavior:
- Only the quote line items matching your filter and/or line numbers are copied to the contract.
- Line item hierarchy and parent-child relationships are preserved for the filtered items.
- The contract header is populated from the quote header per the existing Quote to Contract mapping rules. Account name updates on the contract header are handled programmatically by Professional Services or the customer.
- The source quote remains unchanged after contract creation.
- Resync is not supported: The line item changes made on the quote after the contract is created are not propagated to existing contract line items.
