This API creates product line items.

APISignature
createProductLineItemswebService static List createProductLineItems(Apttus_Config2__ProductConfiguration__c configSO, Apttus_Config2.CPQStruct.ProductCollDO prodCollDO)


Request Parameter
NameTypeDescription
configSOApttus_Config2__ProductConfiguration__cThe ID of product configuration sobject.
prodCollDOApttus_Config2.CPQStruct.ProductCollDOThe product details request data object



Request Data Object - Apttus_Config2.CPQStruct.ProductCollDO
NameTypeDescription
ProductsApttus_Config2.CPQStruct.ProductLineItemDOThe bundle product request data object
HasOptionProductsBooleanIndicate whether has option products or not.
ProductIdsList<ID>The list of product Ids
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
productLineItemsList<Apttus_Config2__LineItem__c>The list of IDs for the new product line items.


Code Sample

The sample code below enables you to create product line items for an existing cart. After the API is executed, the list of line items is returned without committing the 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 create the line items for the Laptop bundle product and also its two options Keyboard and Mouse 
 */
 public List<Apttus_Config2__LineItem__c> createProductLineItems(String proposalID, List<String> bundleProductName) 
 {
	Apttus_Config2__ProductConfiguration__c cart = [SELECT	Apttus_Config2__PriceListId__c,
                                                            Id,
                                                            Apttus_Config2__SummaryGroupType__c,
                                                            Apttus_Config2__ContractNumbers__c,
                                                    		Apttus_Config2__EffectiveDate__c,
                                                    		Apttus_Config2__PurchaseId__c,
                                                    		Apttus_Config2__ExpectedStartDate__c,
                                                    		Apttus_Config2__ExpectedEndDate__c,
                                                    		Apttus_Config2__EffectivePriceListId__c,
                                                    		Apttus_Config2__PriceListId__r.Apttus_Config2__CostModelId__c  
                                                    FROM Apttus_Config2__ProductConfiguration__c 
                                                   	WHERE Apttus_QPConfig__Proposald__r.Name = :proposalID 
                                                   	LIMIT 1];
	
    List<Apttus_Config2.CPQStruct.ProductLineItemDO> prodItems = new List<Apttus_Config2.CPQStruct.ProductLineItemDO>();                                                               
	for(Product2 ProductSO : [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 :bundleProductName]) 
	{ 
		prodItems.add(new Apttus_Config2.CPQStruct.ProductLineItemDO(ProductSO, 10, 1, null, null, 'Comment from API'));
	}
                                                                    
	Apttus_Config2.CPQStruct.ProductCollDO prodCollDO = new Apttus_Config2.CPQStruct.ProductCollDO(prodItems);
	List<Apttus_Config2__LineItem__c> productLineItems = Apttus_Config2.CPQWebService.createProductLineItems(cart,prodCollDO);

    return productLineItems;                                                                
}
CODE