PDF
Download PDF
Download page Creating Product Line Items.
Creating Product Line Items
This API creates product line items.
API | Signature |
---|---|
createProductLineItems | webService static List createProductLineItems(Apttus_Config2__ProductConfiguration__c configSO, Apttus_Config2.CPQStruct.ProductCollDO prodCollDO) |
Request Parameter | ||
---|---|---|
Name | Type | Description |
configSO | Apttus_Config2__ProductConfiguration__c | The ID of product configuration sobject. |
prodCollDO | Apttus_Config2.CPQStruct.ProductCollDO | The product details request data object |
Request Data Object - Apttus_Config2.CPQStruct.ProductCollDO | ||
---|---|---|
Name | Type | Description |
Products | Apttus_Config2.CPQStruct.ProductLineItemDO | The bundle product request data object |
HasOptionProducts | Boolean | Indicate whether has option products or not. |
ProductIds | List<ID> | The list of product Ids |
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 |
productLineItems | List<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