You can use this API to add line items to a specified cart. The line items can be for bundles, standalone products, and options.


This API does not create the associated Product Attribute Value record, you must call the createNewAttributes API right after executing this API.

APISignature
addLineItemswebService static Apttus_CPQApi.CPQ.AddMultiProductResponseDO addLineItems(Id cartId, List lineItems, Apttus_CPQApi.CPQ.AddLineItemsRequestDO optionalParams)



Parameters
FieldTypeDescription
cartIdIDThe ID of the cart.
lineItemsList<Apttus_Config2__LineItem__c>List of LineItems SObject records to be added to the Cart.
optionalParamsApttus_CPQApi.CPQ.AddLineItemsRequestDOAdditional parameter that must not be used for this API.



Response Data Object - 

Apttus_CPQApi.CPQ.AddMultiProductResponseDO

FieldTypeDescription
LineNumbersList<Decimal>Contains List of Line Numbers of the newly added Line Items


Code Sample

The sample code below enables you to add a bundle and an option line item. You must provide values for the following mandatory fields:

  • For bundle
    • ConfigurationId__c
    • ProductId__c
  • For option
    • ConfigurationId__c
    • OptionId__c
    • ParentBundleNumber__c

You can set relevant values on any field when passing the Line Item record in the request. However, you should not set system fields here such as Line Number, Primary Line Number, and Pricing related fields. CPQ manages these fields internally.

// prepare bundle line for input
Product2 bundleProd = [SELECT Id FROM Product2 WHERE Name = 'Patient Accounting'];
Apttus_Config2__LineItem__c bundleLineItemSO = new LineItem__c(Apttus_Config2__ConfigurationId__c = getCartSO().Id);
bundleLineItemSO.Apttus_Config2__ProductId__c = bundleProd.Id;

// prepare option line for input
Product2 optionProd = [SELECT Id FROM Product2 WHERE Name = 'Dell 360'];
Apttus_Config2__LineItem__c optionLineItemSO = new Apttus_Config2__LineItem__c(Apttus_Config2__ConfigurationId__c = getCartSO().Id);
optionLineItemSO.Apttus_Config2__ProductId__c = bundleProd.Id;
optionLineItemSO.Apttus_Config2__OptionId__c = optionProd.Id;
optionLineItemSO.Apttus_Config2__ParentBundleNumber__c = 1;

// add bundle line item
List<Decimal> bundleLineNumbers = CPQWebService.addLineItems (
getCartSO().Id,
new List<Apttus_Config2__LineItem__c>{bundleLineItemSO});

// add option line item
List<Decimal> optionLineNumbers = Apttus_CPQApi.CPQWebService.addLineItems (
getCartSO().Id,
new List<Apttus_Config2__LineItem__c>{optionLineItemSO});
CODE