PDF
Download PDF
Download page Creating Bundle Line Items.
Creating Bundle Line Items
This API creates the bundle and option line items based on the bundle product data object.
API | Signature |
---|---|
createBundleLineItems | webService static List createBundleLineItems(Apttus_Config2__ProductConfiguration__c configSO, Apttus_Config2.CPQStruct.ProductBundleDO bundleDO) |
Request Parameter | ||
---|---|---|
Name | Type | Description |
configSO | Apttus_Config2__ProductConfiguration__c | The ID of product configuration sobject. |
bundleDO | Apttus_Config2.CPQStruct.ProductBundleDO | The bundle details request data object |
Request Data Object - Apttus_Config2.CPQStruct.ProductBundleDO | ||
---|---|---|
Name | Type | Description |
BundleProduct | Apttus_Config2.CPQStruct.ProductLineItemDO | The bundle product request data object |
HasOptionProducts | Boolean | Indicate whether has option products or not. |
OptionProductIds | List<ID> | The list of option product Ids |
OptionProducts | ListList<ProductLineItemDO> | The list of option product data objects. |
Data Object - Apttus_Config2.CPQStruct.ProductLineItemDO | ||
---|---|---|
Name | Type | Description |
AddedBy | String | Indicate how was the product added. For example, added by constraint rule, APIs. |
Comments | String | The comments added in the product. |
CustomData | Apttus_Config2__LineItem__c | The custom data based on list of custom fields to initialize Line Item record. |
CustomFields | List<String> | List of Custom Fields. |
EndDate | Date | The end date of the product. |
productOptionComponentId | ID | The ID of the Product Option Component (only for option products). |
ProductSO | Product2 | The product sobject. |
Quantity | Decimal | The quantity of the product. |
SellingTerm | Decimal | The selling term of the product. |
StartDate | Date | The start date of the product. |
Response Parameters | ||
---|---|---|
Field | Type | Description |
lineItems | List<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