This method allows you to clone the option line items and child line items (if applicable) on the Cart. This API is invoked when you click Clone action icon next to an option product on the Cart.

APISignature
cloneOptionLineItemswebService static Apttus_CPQApi.CPQ.CloneLineItemsResponseDO cloneOptionLineItems(Apttus_CPQApi.CPQ.CloneLineItemsRequestDO request)
Request Parameter
NameTypeDescription

Request

Apttus_CPQApi.CPQ.CloneLineItemsRequestDO

This is the request data object.

Request Data Object – Apttus_CPQApi.CPQ.CloneLineItemsRequestDO
NameTypeDescription

Cart ID

ID

The Id of the cart.

PrimaryLineNumber

Integer

The line numbers of the primary line items which have to be cloned using this API.

Response Data Object – Apttus_CPQApi.CPQ.CloneLineItemsResponseDO
NameTypeDescription

OriginalToCloneMap

List<Apttus_CPQApi.CPQ.IntegerMapDO>

The list of primary line item numbers.

Response Data Object – Apttus_CPQApi.CPQ.IntegerMapDO
NameTypeDescription

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 below code sample, you can clone the option line items after you configure your bundle products, add the attributes and arrive on the cart. This API accepts the Cart ID and the option 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 by adding option products using addoptions API, you can invoke this API in order to clone the option 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 option line items 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 number of the Laptop bundle product
 */
public static void cloneOptionLineItems(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 cloneOptionLineItems routine
		Apttus_CPQApi.CPQ.CloneLineItemsResponseDO response = Apttus_CPQApi.CPQWebService.cloneOptionLineItems(request);
		
		for(Apttus_CPQApi.CPQ.IntegerMapDO intMapDO : response.OriginalToCloneMap) 
		{
			System.debug('Original Primary Line Number = ' + intMapDO.Key + ', Cloned Primary Line Number = ' + intMapDO.Value);
		}
	}
}
CODE

Integration Details

Use the following information in your integrations with Apttus CPQ Web Services API. Refer to Integrating Apttus with External Systems for information on how to get started.

API Prerequisites

Response/Request XML

Example Request (click to expand)

<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!ASAAQGyIEG86MxZJB2SAYAO.SoCSmGG7G3SzeD6x2lnQ_zQCcBu.SpLUCrnOBk0PhOOtnf_OAAnE0nfpZfkaS9mA_1G_1kmP</cpq:sessionId>
        </cpq:SessionHeader>
    </soapenv:Header>
    <soapenv:Body>
        <cpq:cloneOptionLineItems>
            <cpq:request>
                <cpq1:CartId>a1OZ0000002YqyaMAC</cpq1:CartId>
                <cpq1:PrimaryLineNumbers>1</cpq1:PrimaryLineNumbers>
                <cpq1:PrimaryLineNumbers>3</cpq1:PrimaryLineNumbers>
            </cpq:request>
        </cpq:cloneOptionLineItems>
    </soapenv:Body>
</soapenv:Envelope>
XML

Example Response (click to expand)

<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>
        <cloneOptionLineItemsResponse>
            <result>
                <CloneLineItemsResponseDO:OriginalToCloneMap>
                    <CloneLineItemsResponseDO:Key>1</CloneLineItemsResponseDO:Key>
                    <CloneLineItemsResponseDO:Value>9</CloneLineItemsResponseDO:Value>
                </CloneLineItemsResponseDO:OriginalToCloneMap>
                <CloneLineItemsResponseDO:OriginalToCloneMap>
                    <CloneLineItemsResponseDO:Key>3</CloneLineItemsResponseDO:Key>
                    <CloneLineItemsResponseDO:Value>12</CloneLineItemsResponseDO:Value>
                </CloneLineItemsResponseDO:OriginalToCloneMap>
            </result>
        </cloneOptionLineItemsResponse>
    </soapenv:Body>
</soapenv:Envelope>
XML