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.
API
Signature
addLineItems
webService static Apttus_CPQApi.CPQ.AddMultiProductResponseDO addLineItems(Id cartId, List lineItems, Apttus_CPQApi.CPQ.AddLineItemsRequestDO optionalParams)
Parameters
Field
Type
Description
cartId
ID
The ID of the cart.
lineItems
List<Apttus_Config2__LineItem__c>
List of LineItems SObject records to be added to the Cart.
optionalParams
Apttus_CPQApi.CPQ.AddLineItemsRequestDO
Additional parameter that must not be used for this API.
Response Data Object -
Apttus_CPQApi.CPQ.AddMultiProductResponseDO
Field
Type
Description
LineNumbers
List<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});