Download PDF
Download page Cloning Line Items on the Cart.
Cloning Line Items on the Cart
This method enables you to clone the primary line items on the Cart. This API is invoked when you click Clone action icon next to a standalone product on the Cart.
API | Signature |
---|---|
cloneLineItems | webService static Apttus_CPQApi.CPQ.CloneLineItemsResponseDO cloneLineItems(Apttus_CPQApi.CPQ.CloneLineItemsRequestDO request) |
Request Parameter | ||
---|---|---|
Name | Type | Description |
Request | Apttus_CPQApi.CPQ.CloneLineItemsRequestDO | This is the request data object. |
Request Data Object – Apttus_CPQApi.CPQ.CloneLineItemsRequestDO | ||
---|---|---|
Name | Type | Description |
Cart ID | ID | The Id of the cart. |
PrimaryLineNumber | Integer | The line item numbers of the primary line items which have to be cloned using this API. |
Response Data Object – Apttus_CPQApi.CPQ.CloneLineItemsResponseDO | ||
---|---|---|
Name | Type | Description |
OriginalToCloneMap | List<Apttus_CPQApi.CPQ.IntegerMapDO> | The list of primary line item numbers. |
Response Data Object – Apttus_CPQApi.CPQ.IntegerMapDO | ||
---|---|---|
Name | Type | Description |
mapItem.Key | Integer | The line item numbers of the source primary line item from which new line items are cloned using this API. |
mapItem.Value | Integer | The line item numbers of the cloned line items. |
Code Sample
Using the following sample, you can clone the primary line items after you configure your products, add the attributes and arrive on the cart. This API accepts the Cart ID and the primary line item numbers, and clones these line items. In the form of the response, this API provides the original line items in the mapItem.Key
parameter and the newly cloned line items in the mapItem.Value
parameter.
For example, once you configure your cart using addMultiProducts API, you can invoke this API in order to clone the line items on the cart at any of the following:
- After the product is added on the Cart.
- Before making changes to pricing of the products.
- After updating the cart pricing using updatePriceForCart API.
.
/**
* The below method demonstrates how to clone standalone product in an existing cart (every quote has a cart)
* Lets assume the Quote's Cart has a 3 products,
* Laptop is a bundle product (line number 1) and Monitor and Wifi Router are standalone products (line number 2 and 3 respectively)
* The input of this method is Quote Number and the line numbers of the Monitor and Wifi Router are standalone products
*/
public static void cloneLineItems(String quoteNumber, List<Integer> primaryLineNumbers)
{
List<Apttus_Config2__ProductConfiguration__c> cart = [SELECT Id FROM Apttus_Config2__ProductConfiguration__c WHERE Apttus_QPConfig__Proposald__r.Name = :quoteNumber LIMIT 1];
if(!cart.isEmpty() && primaryLineNumbers != null && !primaryLineNumbers.isEmpty())
{
// Create the request object
Apttus_CPQApi.CPQ.CloneLineItemsRequestDO request = new Apttus_CPQApi.CPQ.CloneLineItemsRequestDO();
request.CartId = cart.get(0).Id;
request.PrimaryLineNumbers = primaryLineNumbers;
// Execute the cloneLineItems routine
Apttus_CPQApi.CPQ.CloneLineItemsResponseDO response = Apttus_CPQApi.CPQWebService.cloneLineItems(request);
for(Apttus_CPQApi.CPQ.IntegerMapDO intMapDO : response.OriginalToCloneMap)
{
System.debug('Source Bundle Line Number = ' + intMapDO.Key + ', Cloned Bundle Line Number = ' + intMapDO.Value);
}
}
}
Integration Details
Use the following information in your integrations with CPQ Web Services API. Refer to Integrating Conga with External Systems for information on how to get started.
API Prerequisites
Response/Request XML
Example Request
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:cpq="http://soap.sforce.com/schemas/class/Apttus_CPQApi/CPQWebService"
xmlns:cpq1="http://soap.sforce.com/schemas/class/Apttus_CPQApi/CPQ">
<soapenv:Header>
<cpq:SessionHeader>
<cpq:sessionId>00DZ000000NAEIA!ASAAQGrz6Z.wmD7Foe_ZhEj44N.Sh34lJRyn0uiVnJa1hQAZgWx3lQ2kM._9AWarlZiTn5kpbVtSuMZEgdXN_Mlze.kGwLVg</cpq:sessionId>
</cpq:SessionHeader>
</soapenv:Header>
<soapenv:Body>
<cpq:cloneLineItems>
<cpq:request>
<cpq1:CartId>a1OZ0000002YotOMAS</cpq1:CartId>
<cpq1:PrimaryLineNumbers>1</cpq1:PrimaryLineNumbers>
<cpq1:PrimaryLineNumbers>2</cpq1:PrimaryLineNumbers>
<cpq1:PrimaryLineNumbers>5</cpq1:PrimaryLineNumbers>
</cpq:request>
</cpq:cloneLineItems>
</soapenv:Body>
</soapenv:Envelope>
Example Response
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns="http://soap.sforce.com/schemas/class/Apttus_CPQApi/CPQWebService"
xmlns:CloneLineItemsResponseDO="http://soap.sforce.com/schemas/class/Apttus_CPQApi/CPQ">
<soapenv:Body>
<cloneLineItemsResponse>
<result>
<CloneLineItemsResponseDO:OriginalToCloneMap>
<CloneLineItemsResponseDO:Key>1</CloneLineItemsResponseDO:Key>
<CloneLineItemsResponseDO:Value>6</CloneLineItemsResponseDO:Value>
</CloneLineItemsResponseDO:OriginalToCloneMap>
<CloneLineItemsResponseDO:OriginalToCloneMap>
<CloneLineItemsResponseDO:Key>2</CloneLineItemsResponseDO:Key>
<CloneLineItemsResponseDO:Value>7</CloneLineItemsResponseDO:Value>
</CloneLineItemsResponseDO:OriginalToCloneMap>
<CloneLineItemsResponseDO:OriginalToCloneMap>
<CloneLineItemsResponseDO:Key>5</CloneLineItemsResponseDO:Key>
<CloneLineItemsResponseDO:Value>8</CloneLineItemsResponseDO:Value>
</CloneLineItemsResponseDO:OriginalToCloneMap>
</result>
</cloneLineItemsResponse>
</soapenv:Body>
</soapenv:Envelope>