You can invoke this global method for asset cancellation.

APISignature
cancelAssetsstatic Apttus_Config2.CPQStruct.CancelAssetsResponseDO cancelAssets(Apttus_Config2.CPQStruct.CancelAssetsRequestDO request)
Parameters

Name

Type

Description

request

Apttus_Config2.CPQStruct.CancelAssetsRequestDO

Request object invoked by the method

Request Data Object - Apttus_Config2.CPQStruct.CancelAssetsRequestDO

Name

Type

Description

CancelDate

Date

The termination date of the Asset

AssetIds

List<ID>

List of asset ids to terminate.

CartId

ID

The id of Cart for which an asset is being canceled.

Response Data Object - Apttus_Config2.CPQStruct.CancelAssetsResponseDO

Field

Type

Description

LineItemMap

Map <ID, Apttus_Config2__LineItem__c>

Line Items that are to be terminated.


Code Sample

The code sample below helps you terminate Assets based on the Termination Date.

// create list of asset ids
List<ID> listAssetId = new List<ID>();
for (AssetLineItemWrapperClass record : wrapperAssetLineItemList)
{
    if (record.selected) 
	{
        listAssetId.add(record.assetId);
    }
}

// create and populate request object
if (objAssetLineItem.Apttus_Config2__CancelledDate__c != null){
    Apttus_Config2.CPQStruct.CancelAssetsRequestDO request = new Apttus_Config2.CPQStruct.CancelAssetsRequestDO();
    request.CancelDate = objAssetLineItem.Apttus_Config2__CancelledDate__c.date();
    request.AssetIds = listAssetId;
    request.CartId = cartId;
}

// call cancelAssets API
Apttus_Config2.CPQStruct.CancelAssetsResponseDO response = Apttus_Config2.AssetService.cancelAssets(request);

ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.info,'cancelAssets: ' + response));
CODE