Creating and Updating Related Line Items
You can use this global method to create related line items records of an asset and associate them with a given service product. You can also delete the related line item. You can create and delete related line items for multiple service products in a single call, however, the number of line items must adhere to the Salesforce Governor Limits.
API |
Signature |
---|---|
updateRelatedLineItems |
static Apttus_Config2.CPQStruct.UpdateRelatedLineItemResponseDO updateRelatedLineItems(Apttus_Config2.CPQStruct.UpdateRelatedLineItemRequestDO requestDO) |
Parameters |
||
---|---|---|
Name |
Type |
Description |
requestDO | Apttus_Config2.CPQStruct.UpdateRelatedLineItemRequestDO |
Request related line item details data object that is invoked by the method. |
Request Data Object - Apttus_Config2.CPQStruct.UpdateRelatedLineItemResponseDO |
||
---|---|---|
Name |
Type |
Description |
CartId | ID |
The ID of the product configuration. |
RelatedLineItemColls | Map<Id,
List<Apttus_Config2.RelatedLineItemColl>> |
Map of service line item id to the list of data objects containing relevant details of the asset associated with the given service line item. |
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 to be saved in the database. |
Response Data Object - Apttus_Config2.CPQStruct.UpdateRelatedLineItemResponseDO |
||
---|---|---|
Field |
Type |
Description |
Errors | List <Strings> |
List of errors encountered while creating or deleting the related line item |
isSuccess | Boolean |
Indicates whether the related line items were created or deleted successfully. |
Code Sample
The code sample below helps you create and delete a related line item.
public void addRemoveRelatedLineItems(String lineItemId, String assetId1, String assetId2, String assetId3, String cartId)
{
// Use LineAction.Add to create new RLI to associate an Asset with Service Line Item
Apttus_Config2.CPQStruct.RelatedLineItemColl relatedLineItemDO1 = new Apttus_Config2.CPQStruct.RelatedLineItemColl();
relatedLineItemDO1.AssetLineItemId = assetId1;
relatedLineItemDO1.Action = 'Add';
Apttus_Config2.CPQStruct.RelatedLineItemColl relatedLineItemDO2 = new Apttus_Config2.CPQStruct.RelatedLineItemColl();
relatedLineItemDO2.AssetLineItemId = assetId2;
relatedLineItemDO2.Action = 'Add';
// Use LineAction.Remove to delete existing RLI for dissociating an Asset from Service Line
Apttus_Config2.CPQStruct.RelatedLineItemColl relatedLineItemDO3 = new Apttus_Config2.CPQStruct.RelatedLineItemColl();
relatedLineItemDO3.AssetLineItemId = assetId3;
relatedLineItemDO3.Action = 'Delete';
// Prepare the request structure to be passed to the API
Apttus_Config2.CPQStruct.UpdateRelatedLineItemRequestDO requestDO = new Apttus_Config2.CPQStruct.UpdateRelatedLineItemRequestDO();
requestDO.RelatedLineItemColls.put(lineItemId, new List<Apttus_Config2.CPQStruct.RelatedLineItemColl>{relatedLineItemDO1, relatedLineItemDO2, relatedLineItemDO3});
requestDO.CartId = cartId;
// Invoke the API by passing the request formed above
Apttus_Config2.CPQStruct.UpdateRelatedLineItemResponseDO responseDO = Apttus_Config2.CPQWebService.updateRelatedLineItems(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);
}
}
}
}