The global method fetches a list of products that are to be swapped.

Ensure that the Replacement Rule is active for Swapping Assets.

APISignature
getSwappedProductsstatic Apttus_Config2.CPQStruct.RecommendationResponseDO getSwappedProducts(Apttus_Config2.CPQStruct.RecommendationRequestDO request)
Parameters

Name

Type

Description

request

Apttus_Config2.CPQStruct.RecommendationRequestDO

Request object invoked by the method

Request Data Object - Apttus_Config2.CPQStruct.RecommendationRequestDO()

Name

Type

Description

CartId

Id

Id of Cart for which Swap action is performed

ProductIds

List<ID>

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

Response Data Object - Apttus_Config2.CPQStruct.RecommendationResponseDO

Field

Type

Description

ProductIds

List<ID>

Ids of products that can be swapped with assets.


Code Sample

The code sample below helps you fetch the list of Product Ids that can be swapped with Assets.

// 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
Apttus_Config2.CPQStruct.RecommendationRequestDO request = new Apttus_Config2.CPQStruct.RecommendationRequestDO();
request.cartId = cartId;
request.ProductIds = listProductId;

// call getSwappedProducts API
Apttus_Config2.CPQStruct.RecommendationResponseDO response = Apttus_Config2.AssetService.getSwappedProducts(request);

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