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

APISignature
cloneBundleLineItemswebService static Apttus_CPQApi.CPQ.CloneLineItemsResponseDO cloneBundleLineItems(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. 

You must pass the value Apttus_Config2__LineNumber_c field instead of Apttus_Config2__PrimaryLineNumber_c to clone bundles. 

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 sample, you can clone the primary bundle line items after you configure your products, add the attributes, configure your options and arrive on the cart. This API accepts the Cart ID and the primary bundle and option line item numbers. In the form of 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 products using addBundle or addMultiProducts API, you can invoke this API in order to clone the bundle and 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 bundle 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 number of the Laptop bundle product
 */
public static void cloneBundleLineItems(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 cloneBundleLineItems routine
		Apttus_CPQApi.CPQ.CloneLineItemsResponseDO response = Apttus_CPQApi.CPQWebService.cloneBundleLineItems(request);
		
		for(Apttus_CPQApi.CPQ.IntegerMapDO intMapDO : response.OriginalToCloneMap)
		{
			System.debug('Source Bundle Line Number = ' + intMapDO.Key + ', Cloned Bundle Line Number = ' + intMapDO.Value);
		}
	}
}
CODE

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:cloneBundleLineItems>
            <cpq:request>
                <cpq1:CartId>a1OZ0000002YouHMAS</cpq1:CartId>
                <cpq1:PrimaryLineNumbers>3</cpq1:PrimaryLineNumbers>
                <cpq1:PrimaryLineNumbers>4</cpq1:PrimaryLineNumbers>
            </cpq:request>
        </cpq:cloneBundleLineItems>
    </soapenv:Body>
</soapenv:Envelope>
XML

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>
        <cloneBundleLineItemsResponse>
            <result>
                <CloneLineItemsResponseDO:OriginalToCloneMap>
                    <CloneLineItemsResponseDO:Key>3</CloneLineItemsResponseDO:Key>
                    <CloneLineItemsResponseDO:Value>5</CloneLineItemsResponseDO:Value>
                </CloneLineItemsResponseDO:OriginalToCloneMap>
                <CloneLineItemsResponseDO:OriginalToCloneMap>
                    <CloneLineItemsResponseDO:Key>4</CloneLineItemsResponseDO:Key>
                    <CloneLineItemsResponseDO:Value>6</CloneLineItemsResponseDO:Value>
                </CloneLineItemsResponseDO:OriginalToCloneMap>
            </result>
        </cloneBundleLineItemsResponse>
    </soapenv:Body>
</soapenv:Envelope>
XML