This API creates the bundle and option line items based on the bundle product data object.

APISignature
createBundleLineItemswebService static List createBundleLineItems(Apttus_Config2__ProductConfiguration__c configSO, Apttus_Config2.CPQStruct.ProductBundleDO bundleDO)



Request Parameter
NameTypeDescription
configSOApttus_Config2__ProductConfiguration__cThe ID of product configuration sobject.
bundleDOApttus_Config2.CPQStruct.ProductBundleDOThe bundle details request data object



Request Data Object - Apttus_Config2.CPQStruct.ProductBundleDO
NameTypeDescription
BundleProduct

Apttus_Config2.CPQStruct.ProductLineItemDO

The bundle product request data object
HasOptionProductsBooleanIndicate whether has option products or not.
OptionProductIdsList<ID>The list of option product Ids
OptionProductsListList<ProductLineItemDO>
The list of option product data objects.
Data Object - Apttus_Config2.CPQStruct.ProductLineItemDO
NameTypeDescription
AddedByStringIndicate how was the product added. For example, added by constraint rule, APIs.
CommentsStringThe comments added in the product.
CustomDataApttus_Config2__LineItem__cThe custom data based on list of custom fields to initialize Line Item record.
CustomFieldsList<String>List of Custom Fields.
EndDateDateThe end date of the product.
productOptionComponentIdIDThe ID of the Product Option Component (only for option products).
ProductSOProduct2The product sobject.
QuantityDecimalThe quantity of the product.
SellingTermDecimalThe selling term of the product.
StartDateDateThe start date of the product.
Response Parameters
FieldTypeDescription
lineItemsList<Apttus_Config2__LineItem__c>The list of IDs for the new bundle line items.


Code Sample

The sample code below enables you to create bundle and option line items for an existing cart. This API returns the list of line items without committing changes into Salesforce. These line items can be used for further modification and later associate to cart by performing insert operation.

/**
 * The below method demonstrates how to create bundle lineitems with option  (every quote has a cart)
 * Let’s assume the Quote's Cart is not blank and Laptop is a bundle product and its two options are Keyboard and Mouse
 * The input of this method is Quote Number and the bundle and related option product names
 * Inside the method we will return the line items for the Laptop bundle product and also its two options Keyboard and Mouse 
 */

public List<Apttus_Config2__LineItem__c> createBundleLineItems(String proposalID, String bundleProductName, List<String> optionProductNames)
{

	Apttus_Config2__ProductConfiguration__c cart = [SELECT Apttus_Config2__PriceListId__c, 
															Id, 
															Apttus_Config2__SummaryGroupType__c,
															Apttus_Config2__ContractNumbers__c 
													FROM Apttus_Config2__ProductConfiguration__c 
													WHERE Apttus_QPConfig__Proposald__r.Name = :proposalID
													LIMIT 1];    
    //Add bundle product data object
	Product2 bundleProductSO = [SELECT ID, 
										Apttus_Config2__Uom__c, 
										Name, Apttus_Config2__Customizable__c, 
										Apttus_Config2__HasDefaults__c, 
										Apttus_Config2__HasAttributes__c, 
										Apttus_Config2__HasOptions__c 
								FROM Product2
								WHERE Name = :bundleProductName 
								LIMIT 1];
	Apttus_Config2.CPQStruct.ProductLineItemDO BundleProduct = new Apttus_Config2.CPQStruct.ProductLineItemDO( bundleProductSO,
                                                                 10,   //quantity assigned to the product
                                                                 1,    //selling term for the product  
                                                                 null, //Start date
                                                                 null, //End date
                                                                 'Comment from API');
    List<Apttus_Config2.CPQStruct.ProductLineItemDO> optionProducts = new List<Apttus_Config2.CPQStruct.ProductLineItemDO>();  
	for (Product2 optionProductSO : [SELECT ID,
                                     Apttus_Config2__Uom__c,
                                     Name,
                                     Apttus_Config2__Customizable__c,
                                     Apttus_Config2__HasDefaults__c,
                                     Apttus_Config2__HasAttributes__c,
                                     Apttus_Config2__HasOptions__c 
									FROM Product2 
                                	WHERE Name IN :optionProductNames]) 
	{
		optionProducts.add(new Apttus_Config2.CPQStruct.ProductLineItemDO(optionProductSO,5,1, null,null,'Comment from API'));
   	} 
	Apttus_Config2.CPQStruct.ProductBundleDO bundleDO = new Apttus_Config2.CPQStruct.ProductBundleDO(BundleProduct, optionProducts);
	List<Apttus_Config2__LineItem__c> lineItems = Apttus_Config2.CPQWebService.createBundleLineItems(cart,bundleDO);
    return lineItems;
}
CODE