You can invoke incrementAssets, a global method to increment assets.

MethodSignature
incrementAssetsstatic Apttus_Config2.CPQStruct.IncrementAssetsResponseDO incrementAssets(Apttus_Config2.CPQStruct.IncrementAssetRequestDO request)
Parameters
NameTypeDescription
request

Apttus_Config2.CPQStruct.IncrementAssetRequestDO

Request object invoked by the method

Request Data Object - Apttus_Config2.CPQStruct.IncrementAssetRequestDO
FieldTypeDescription

IncrementAssetDOs

List <Apttus_Config2.CPQStructIncrementAssetDO>

List of increment assets data objects.

CartId

ID

The ID of the cart that consists of assets to be incremented.

Data Object - Apttus_Config2.CPQStruct.IncrementAssetDO
FieldTypeDescription

AssetId

Id

The ID of the Asset you want to apply the increment.

LineAction

String

This defines the update made to the asset. There are two types.

  • Increment: creates a new asset
  • Increment or Merge: updates the existing asset.

NewStartDate

Date

New start date for the updated or new asset.

NewEndDate

Date

New end date for the updated or new asset.

QuantityIntegerThe amount of quantity to be incremented.

Response Data Object- Apttus_Config2.CPQStruct.IncrementAssetsResponseDO

FieldTypeDescription

LineItemMap

Map<ID, Apttus_Config2__LineItem__c>

Returns all line items with all their field values.


Code Sample

The following sample enables you to increment the quantity of standalone products. You can also provide new start and end dates for the products. If you define LineAction as Increment, new assets are created and, if you define LineAction as Increment and Merge, existing assets are updated.

Apttus_Config2.CPQStruct.IncrementAssetRequestDO request = new Apttus_Config2.CPQStruct.IncrementAssetRequestDO(); 

for (AssetLineItemWrapperClass record : wrapperAssetLineItemList) 
{
     if (record.selected) 
	{
          // create and populate request object 
          Apttus_Config2.CPQStruct.IncrementAssetDo assetDO = new Apttus_Config2.CPQStruct.IncrementAssetDO();
          assetDO.AssetId = record.assetId; 
          assetDO.NewStartDate = record.objAssetLineItem.Apttus_Config2__StartDate__c;
          assetDO.NewEndDate = record.objAssetLineItem.Apttus_Config2__EndDate__c;
          assetDO.Quantity = record.objAssetLineItem.Apttus_Config2__Quantity__c;
          assetDO.LineAction = 'Increment'; // Or 'Increment and Merge'
          request.IncrementAssetDOs.add(assetDO);
     }
}
request.CartId = cartId;

// call incrementAssets API 
Apttus_Config2.CPQStruct.IncrementAssetsResponseDO response =    Apttus_Config2.AssetService.incrementAssets(request);
ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.info, incrementAssets: ' + response));
CODE