You can invoke this API for swapping Assets.

APISignature
swapAssetsstatic Apttus_Config2.CPQStruct.SwapAssetsResponseDO swapAssets(Apttus_Config2.CPQStruct.SwapAssetsRequestDO request)
Parameters

Name

Type

Description

request

Apttus_Config2.CPQStruct.SwapAssetsRequestDO

Request object invoked by the method

Request Data Object - Apttus_Config2.CPQStruct.SwapAssetsRequestDO

Name

Type

Description

NewStartDate

Date

The new Asset Start Date on Swapping

ProductIds

List<ID>

Id of the product with which the Asset is being swapped.

AssetIds

List<ID>

The Id of the Asset which is swapped.

CartIds

Id

The Id of Cart for which an Asset is being swapped

Response Data Object - Apttus_Config2.CPQStruct.SwapAssetsResponseDO

Field

Type

Description

LineItemMap

Map<ID, Apttus_Config2__LineItem__c>

Map of line items of the assets that are being swapped.


Code Sample

The code sample below helps you swap an Asset with another product.

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

// create list of product ids
List<ID> listProductId = new List<ID>();
for (ProductWrapperClass product : wrapperProductList) 
{
    if (product.selected) 
	{
        listProductId.add(product.productId);
    } 
}

// create and populate request object
if (objAssetLineItem.Apttus_Config2__StartDate__c != null) 
{
    Apttus_Config2.CPQStruct.SwapAssetsRequestDO request = new Apttus_Config2.CPQStruct.SwapAssetsRequestDO(); 
    request.AssetIds = listAssetId;
    request.ProductIds = listProductId;
    request.NewStartDate = objAssetLineItem.Apttus_Config2__StartDate__c;
    request.CartId = cartId;
}

// call swapAssets API
Apttus_Config2.CPQStruct.SwapAssetsResponseDO response = Apttus_Config2.AssetService.swapAssets(request);

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