Saving Related Line Items
You can use this global method to save modified related line items. You can modify the following fields in the related line items:
- Weightage Type
- Weightage Percent
- Weightage Amount
- Any custom fields
|
API |
Signature |
|---|---|
| saveRelatedLineItems |
static Apttus_Config2.CPQStruct.SaveRelatedLineItemResponseDO saveRelatedLineItems(Apttus_Config2.CPQStruct.SaveRelatedLineItemRequestDO requestDO) |
|
Parameters |
||
|---|---|---|
|
Name |
Type |
Description |
| requestDO | Apttus_Config2.CPQStruct.SaveRelatedLineItemRequestDO |
The related line item request data object. |
|
Request Data Object - Apttus_Config2.CPQStruct.SaveRelatedLineItemRequestDO |
||
|---|---|---|
|
Name |
Type |
Description |
| CartId | ID |
The ID of the product configuration where you want to save the modified related line item. |
| RelatedLineItem | List<Apttus_Config2.RelatedLineItemColl> |
List of related line items to be saved in the database. |
|
Data Object - Apttus_Config2.RelatedLineItemColl |
||
|---|---|---|
|
Name |
Type |
Description |
| Action | String |
Define one of the following strings to specify whether associate or dissociate the asset from the service line item:
|
| AssetLineItemId | Id |
The Id of the asset line item |
| RelatedLineItemSO | Apttus_Config2__RelatedLineItem__c |
The Sobject with the updated values of related line items to be saved in the database. |
|
Response Data Object - Apttus_Config2.CPQStruct.SaveRelatedLineItemResponseDO |
||
|---|---|---|
|
Field |
Type |
Description |
| Errors | List <Strings> |
List of errors encountered while saving the related line item |
| isSuccess | Boolean |
Indicates whether the related line items were saved successfully. |
Code Sample
The code sample below helps you save related line items.
public void saveRelatedLineItems(String cartId, String lineItemId) {
// Prepare the request structure to be passed to the API
Apttus_Config2.CPQStruct.SaveRelatedLineItemRequestDO requestDO = new Apttus_Config2.CPQStruct.SaveRelatedLineItemRequestDO();
requestDO.CartId = cartId;
List<Apttus_Config2__RelatedLineItem__c> relatedLineItemSOs = [SELECT Apttus_Config2__LineItemId__c, Apttus_Config2__WeightageType__c, Apttus_Config2__WeightageAmount__c FROM Apttus_Config2__RelatedLineItem__c WHERE Apttus_Config2__LineItemId__c =: lineItemId];
// below is simple example logic to set the Weightage Amount and setting Weightage type to Amount
// Customers can have their use cases implemented here
for (Apttus_Config2__RelatedLineItem__c relatedLineItemSO : relatedLineItemSOs) {
relatedLineItemSO.Apttus_Config2__WeightageType__c = 'Amount';
relatedLineItemSO.Apttus_Config2__WeightageAmount__c = 35;
Apttus_Config2.CPQStruct.RelatedLineItemColl relatedLineItemDO = new Apttus_Config2.CPQStruct.RelatedLineItemColl();
relatedLineItemDO.RelatedLineItemSO = relatedLineItemSO;
requestDO.RelatedLineItems.add(relatedLineItemDO);
}
// Invoke the API by passing the request formed above
Apttus_Config2.CPQStruct.SaveRelatedLineItemResponseDO responseDO = Apttus_Config2.CPQWebService.saveRelatedLineItems(requestDO);
// Check the response for errors if any
if (!responseDO.IsSuccess) {
System.debug('Errors thrown :');
if (responseDO.Errors != null && responseDO.Errors.size() > 0) {
for (String strError : responseDO.Errors) {
System.debug('\nError - ' + strError);
}
}
}
}
