This API enables you to remove specific line items from the Cart. This API is invoked when you click Remove action icon next to any product on the Cart.

APISignature
removeLineItemswebService static Apttus_CPQApi.CPQ.RemoveLineItemsResponseDO removeLineItems(Apttus_CPQApi.CPQ.RemoveLineItemsRequestDO request)
Request Parameter
NameTypeDescription

Request

Apttus_CPQApi.CPQ.RemoveLineItemsRequestDO

This is the request data object.

Request Data Object – Apttus_CPQApi.CPQ.RemoveLineItemsRequestDO
NameTypeDescription

Cart ID

ID

The Id of the cart.

PrimaryLineNumbers

Integer

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

Response Data Object – Apttus_CPQApi.CPQ.RemoveLineItemsResponseDO
NameTypeDescription

IsSuccess

Boolean

Indicates whether the operation of removing the line items was a success. True indicates success, false indicates that the line items were not removed from the Cart.


Code sample

You can use this API after you realize that the end-user has added some products (bundle, standalone, or option) and you want to remove those products from the Cart at once. Along with the primary line items, this API also removes the child line items under these primary line items (if applicable).


/**
 * The below method demonstrates how to remove multiple line items from an existing cart (every quote has a cart)
 * Lets assume the Quote's Cart has 3 products,
 * a bundle product called Laptop (line number 1) and its two options are Keyboard and Mouse
 * 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 Laptop bundle product and Monitor standalone product
 */
public static void removeLineItems(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.RemoveLineItemsRequestDO request = new Apttus_CPQApi.CPQ.RemoveLineItemsRequestDO();
		request.CartId = cart.get(0).Id;
		request.PrimaryLineNumbers = primaryLineNumbers;
		
		// Execute the removeLineItems routine
		Apttus_CPQApi.CPQ.RemoveLineItemsResponseDO response = Apttus_CPQApi.CPQWebService.removeLineItems(request);
		
		System.debug('Remove line items from cart response status = ' + response.IsSuccess);
	}    	
}
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

<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:removeLineItems>
            <cpq:request>
                <cpq1:CartId>a1OZ0000002YqyaMAC</cpq1:CartId>
                <cpq1:PrimaryLineNumbers>2</cpq1:PrimaryLineNumbers>
                <cpq1:PrimaryLineNumbers>7</cpq1:PrimaryLineNumbers>
            </cpq:request>
        </cpq:removeLineItems>
    </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:RemoveLineItemsResponseDO="http://soap.sforce.com/schemas/class/Apttus_CPQApi/CPQ">
    <soapenv:Body>
        <removeLineItemsResponse>
            <result>
                <RemoveLineItemsResponseDO:IsSuccess>true</RemoveLineItemsResponseDO:IsSuccess>
            </result>
        </removeLineItemsResponse>
    </soapenv:Body>
</soapenv:Envelope>
XML