This method enables you to complete standard asset based ordering actions of renew, terminate, amend, upgrade and increment.

This method creates the cart line item and associates it to the corresponding asset id. Actions can be performed on a single line item or a selected set of asset line items. Actions can also be performed on standalone product or bundle product.

When doing a renewal, you can use any of the standard adjustment types, including % Uplift which is used to pass an uplift percentage that is applied to the base price of the renewed line item, resulting in an updated net renewal price.


Note

CartIdAssetLineItemId__c, and AssetActions are required parameters, the use of other parameters depends on your business case.

APISignature
modifyAssetwebService static Apttus_CPQApi.CPQ.ModifyAssetResponseDO modifyAsset(Apttus_CPQApi.CPQ.ModifyAssetRequestDO request)



Parameters
NameTypeDescription
requestApttus_CPQApi.CPQ.ModifyAssetRequestDOThis is the request call made by the method.



Request Data Object - Apttus_CPQApi.CPQ.ModifyAssetRequestDO
FieldTypeDescription
AssetActionsList<Apttus_CPQApi.CPQ.AssetActionDO>The list of asset actions, which is either Renew, Amend, Increment, Cancel, Upgrade.
CartIdIDThe Id of cart.



Response Data Object - Apttus_CPQApi.CPQ.ModifyAssetResponseDO
FieldTypeDescription
AssetActionsList<Apttus_CPQApi.CPQ.AssetActionDO>The list of asset actions, which is either Renew, Amend, Increment, Cancel, Upgrade.
LineNumberList<Decimal>The asset line number.
Data Object - Apttus_CPQApi.CPQ.AssetActionDO
FieldTypeDescription
AdjustmentAmountDecimalEnter the value (number) for the adjustment. How the value is interpreted is based on the Adjustment Type. For example, 10 with an Adjustment Type of % Uplift means the price will be cut in half, whereas that same value of 10 with an Adjustment Type of Price Override means the price will become 10.
AdjustmentTypeStringThis is the type of adjustment that will be used. You can select from types such as % Discount, Discount Amount, and Price Override. You specific implementation may have more or less types.
AssetActionStringThis is the specific asset action for the asset line item, referenced by AssetLineItemId.
AssetLineItemIdIDThis is the ID for the asset line item that you are going to renew, amend, increment, or cancel. This is mandatory.
CommentsStringText string containing comments.
CustomDataApttus_Config2__LineItem__cThis can be used to include custom fields in line item object.
CustomFieldsListThis can be used to include custom fields you have added to the asset object.
EndDateDateThis is the end date for the asset action. If you are terminating an asset you only need an end date.
MessageStringText string containing comments.
PendingBooleanThis indicates whether an asset action is pending.
QuantityDecimalThe amount of assets.
SellingTermDecimalThis is the selling term of the asset line item that you want to renew, amend, or increment.
StartDateDateThis is the start date for the asset action.


Code Sample

You can amend a list of standalone or bundle products. You can change the dates, quantity, or some options for a product using the Amend API. You can also cancel or change options in an Option Group using Amend.

The Sample below enables you to change amend the start and end date for selected assets of an account. The response returns the lineitem number of the asset to be updated. The assetAction status, the status of the asset is modified and updated. When the customer clicks Amend, you can invoke the modifyAssets API and choose to amend the date, quantity.

public void Amend()
{
//Create an assetAction variable with value as amend
	string assetAction = 'Amend';

	List<Apttus_CPQApi.CPQ.AssetActionDO> assetActDOList = new List<Apttus_CPQApi.CPQ.AssetActionDO>();
	
//If Asset is selected in the cart page, execute the loop
for(AssetWrapperClass objAssetWrapper : lstAssetWrapper) 
	{
		if(objAssetWrapper.selected)
		{
			Apttus_CPQApi.CPQ.AssetActionDO assetActDO = new Apttus_CPQApi.CPQ.AssetActionDO();
			assetActDO.AssetAction = assetAction;
			assetActDO.AssetLineItemId = objAssetWrapper.AssetId ;
//Change the end date to five months from start date			
			assetActDO.EndDate = Date.today().addMonths(5);
//assetAction pending is true			
			assetActDO.Pending = true;
			assetActDO.Quantity = objAssetWrapper.Quantity;
//Amend the start date to include today's date
			assetActDO.StartDate = Date.today().addMonths(0);

			List<String> customFields = new List<String>();
			customFields.add('Apttus_Config2__Comments__c');
			customFields.add('Apttus_Config2__PricingStatus__c');
			
			assetActDO.CustomFields = customFields;
			
			Apttus_Config2__LineItem__c liSO = new Apttus_Config2__LineItem__c();
			liSO.Apttus_Config2__Comments__c = 'Comments Added my Modify Asset API Code';
			liSO.Apttus_Config2__PricingStatus__c = 'Complete';
			assetActDO.CustomData = liSO;            
			
			assetActDOList.add(assetActDO);
		}
	}
	
//Execute the API for a specific cart using CartID
	Apttus_CPQApi.CPQ.ModifyAssetRequestDO modifyRequest = new Apttus_CPQApi.CPQ.ModifyAssetRequestDO();
	modifyRequest.CartId = cartID;
	modifyRequest.AssetActions = assetActDOList;
	
	Apttus_CPQApi.CPQ.ModifyAssetResponseDO modifyReponse = Apttus_CPQApi.CPQWebservice.modifyAsset(modifyRequest);
	
	List<Decimal> lineNumberList = modifyReponse.LineNumbers;
	
	List<Apttus_CPQApi.CPQ.AssetActionDO> assetList = modifyReponse.AssetActions;
	
//Signifies the status of the assetAction
	Boolean bIsPending = false;

	Integer iCounter = 0;
	
	while (iCounter < 1000) 
	{
		bIsPending = false;
		for(Apttus_CPQApi.CPQ.AssetActionDO objAsset: assetList)
		{
			if(objAsset.Pending == true)
			{
				bIsPending = true;
				break;
			}
		}
//If the asset action is pending execute the loop below to change the status
		if(bIsPending == true)
		{
			modifyReponse = Apttus_CPQApi.CPQWebservice.modifyAsset(modifyRequest);
			lineNumberList = modifyReponse.LineNumbers;
			assetList = modifyReponse.AssetActions;
		}
		else
		{
			break;
		}
		iCounter++;
	}
	
	bindAssets();
}
//This function enables you to bind updated assets to an account dynamically.
public void bindAssets()
{
	List<Apttus_Config2__AssetLineItem__c> aliSOList = [select id, Apttus_Config2__Description__c,
	Apttus_Config2__Quantity__c, Apttus_Config2__StartDate__c, Apttus_Config2__EndDate__c from Apttus_Config2__AssetLineItem__c
	where Apttus_Config2__AccountID__c = :accountID];

	lstAssetWrapper = new List<AssetWrapperClass>();
	
	for(Apttus_Config2__AssetLineItem__c aliSO : aliSOList) 
	{
		AssetWrapperClass objAssetWrapperClass = new AssetWrapperClass ();
		objAssetWrapperClass.AssetId = aliSO.ID;
		objAssetWrapperClass.ProductId = aliSO.Apttus_Config2__Description__c;
		objAssetWrapperClass.Quantity = aliSO.Apttus_Config2__Quantity__c;
		objAssetWrapperClass.StartDate = aliSO.Apttus_Config2__StartDate__c;
		objAssetWrapperClass.EndDate = aliSO.Apttus_Config2__EndDate__c;
		
		lstAssetWrapper.Add(objAssetWrapperClass);
	}
}
CODE


You can renew a list of standalone or bundled products. You can choose to renew recurring items, overall bundle, and recurring options. You can also cancel or change the quantity, price, or an entire option. The sample below enables you to renew the assets. When the user selects an asset and clicks renew, invoke this API and use the sample below to extend the end date of the assets by 12 months.


public void ReNew()
{
//Declare assetAction variable with value as Renew
	string assetAction = 'Renew';        
	List<Apttus_CPQApi.CPQ.AssetActionDO> assetActDOList = new List<Apttus_CPQApi.CPQ.AssetActionDO>();
	
	//For a selected asset you can execute the loop
	for(AssetWrapperClass objAssetWrapper : lstAssetWrapper) 
	{
		if(objAssetWrapper.selected)
		{
			Apttus_CPQApi.CPQ.AssetActionDO assetActDO = new Apttus_CPQApi.CPQ.AssetActionDO();
			assetActDO.AssetAction = assetAction;
			assetActDO.AssetLineItemId = objAssetWrapper.AssetId ;
			
			//Enables you to set end date as 12 months from the existing end date
			assetActDO.EndDate = objAssetWrapper.EndDate.addMonths(12);
			assetActDO.Pending = true;
			assetActDO.Quantity = objAssetWrapper.Quantity;
			
			//Increment start date by One day from the existing start date			
			assetActDO.StartDate = objAssetWrapper.EndDate.addDays(1);

			List<String> customFields = new List<String>();
			customFields.add('Apttus_Config2__Comments__c');
			customFields.add('Apttus_Config2__PricingStatus__c');
			assetActDO.CustomFields = customFields;
			
			//Fetch asset line item number		
			Apttus_Config2__LineItem__c liSO = new Apttus_Config2__LineItem__c();
			liSO.Apttus_Config2__Comments__c = 'Comments Added my Modify Asset API Code';
			liSO.Apttus_Config2__PricingStatus__c = 'Complete';
			assetActDO.CustomData = liSO;            
			assetActDOList.add(assetActDO);
		}
	}
	//Invoke the modify assets API and specify the cart for which the API is invoked.
	Apttus_CPQApi.CPQ.ModifyAssetRequestDO modifyRequest = new Apttus_CPQApi.CPQ.ModifyAssetRequestDO();
	modifyRequest.CartId = cartID;
	modifyRequest.AssetActions = assetActDOList;
	
	Apttus_CPQApi.CPQ.ModifyAssetResponseDO modifyReponse = Apttus_CPQApi.CPQWebservice.modifyAsset(modifyRequest);
	List<Decimal> lineNumberList = modifyReponse.LineNumbers;
	List<Apttus_CPQApi.CPQ.AssetActionDO> assetList = modifyReponse.AssetActions;
	Boolean bIsPending = false;
	Integer iCounter = 0;
	while (iCounter < 1000) 
	{
		bIsPending = false;
		for(Apttus_CPQApi.CPQ.AssetActionDO objAsset: assetList)
		{
			if(objAsset.Pending == true)
			{
				bIsPending = true;
				break;
			}
		}
		
		//If asset Action is pending execute the following loop
		if(bIsPending == true)
		{
			modifyReponse = Apttus_CPQApi.CPQWebservice.modifyAsset(modifyRequest);
			lineNumberList = modifyReponse.LineNumbers;
			assetList = modifyReponse.AssetActions;
		}
		else
		{
			break;
		}
		iCounter++;
	}
	bindAssets();
}

//This function enables you to bind updated asset.
public void bindAssets()
{
	List<Apttus_Config2__AssetLineItem__c> aliSOList = [select id, Apttus_Config2__Description__c,
	Apttus_Config2__Quantity__c, Apttus_Config2__StartDate__c, Apttus_Config2__EndDate__c from Apttus_Config2__AssetLineItem__c
	where Apttus_Config2__AccountID__c = :accountID];

	lstAssetWrapper = new List<AssetWrapperClass>();
	
	for(Apttus_Config2__AssetLineItem__c aliSO : aliSOList) 
	{
		AssetWrapperClass objAssetWrapperClass = new AssetWrapperClass ();
		objAssetWrapperClass.AssetId = aliSO.ID;
		objAssetWrapperClass.ProductId = aliSO.Apttus_Config2__Description__c;
		objAssetWrapperClass.Quantity = aliSO.Apttus_Config2__Quantity__c;
		objAssetWrapperClass.StartDate = aliSO.Apttus_Config2__StartDate__c;
		objAssetWrapperClass.EndDate = aliSO.Apttus_Config2__EndDate__c;
		
		lstAssetWrapper.Add(objAssetWrapperClass);
	}
}
CODE


You can increment the quantity or the dates of the asset items using the increment asset action. For example, the user selects an asset item and clicks Increment. You can use the sample below to update the quantity and the end date by five months and bind the updated assets to the account.


public void Increment()
{
	//Declare the assetAction variable with value as Increment
	string assetAction = 'Increment';

	List<Apttus_CPQApi.CPQ.AssetActionDO> assetActDOList = new List<Apttus_CPQApi.CPQ.AssetActionDO>();
	
	for(AssetWrapperClass objAssetWrapper : lstAssetWrapper) 
	{
		if(objAssetWrapper.selected)
		{
			//For a selected asset increment the quantity by 5 and increment the end date by 5.
			Apttus_CPQApi.CPQ.AssetActionDO assetActDO = new Apttus_CPQApi.CPQ.AssetActionDO();
			assetActDO.AssetAction = assetAction;
			assetActDO.AssetLineItemId = objAssetWrapper.AssetId ;
			assetActDO.EndDate = Date.today().addMonths(5);
			assetActDO.Pending = true;
			assetActDO.Quantity = objAssetWrapper.Quantity + 5;
			assetActDO.StartDate = Date.today().addMonths(0);

			List<String> customFields = new List<String>();
			customFields.add('Apttus_Config2__Comments__c');
			customFields.add('Apttus_Config2__PricingStatus__c');
			
			assetActDO.CustomFields = customFields;
			//Line number of the asset items	
			Apttus_Config2__LineItem__c liSO = new Apttus_Config2__LineItem__c();
			liSO.Apttus_Config2__Comments__c = 'Comments Added my Modify Asset API Code';
			liSO.Apttus_Config2__PricingStatus__c = 'Complete';
			assetActDO.CustomData = liSO;
			assetActDOList.add(assetActDO);
		}
	}
	//Invoke the modifyAsset API to increment the quantity and end date
	Apttus_CPQApi.CPQ.ModifyAssetRequestDO modifyRequest = new Apttus_CPQApi.CPQ.ModifyAssetRequestDO();
	modifyRequest.CartId = cartID;
	modifyRequest.AssetActions = assetActDOList;
	
	Apttus_CPQApi.CPQ.ModifyAssetResponseDO modifyReponse = Apttus_CPQApi.CPQWebservice.modifyAsset(modifyRequest);
	List<Decimal> lineNumberList = modifyReponse.LineNumbers;
	List<Apttus_CPQApi.CPQ.AssetActionDO> assetList = modifyReponse.AssetActions;
	Boolean bIsPending = false;
	Integer iCounter = 0;
	while (iCounter < 1000) 
	{
		bIsPending = false;
		for(Apttus_CPQApi.CPQ.AssetActionDO objAsset: assetList)
		{
			if(objAsset.Pending == true)
			{
				bIsPending = true;
				break;
			}
		}
		
		//If asset action is pending, execute this loop
		if(bIsPending == true)
		{
			modifyReponse = Apttus_CPQApi.CPQWebservice.modifyAsset(modifyRequest);
			lineNumberList = modifyReponse.LineNumbers;
			assetList = modifyReponse.AssetActions;
		}
		else
		{
			break;
		}
		iCounter++;
	}
	
	bindAssets();
}

//Bind updated asset items
public void bindAssets()
{
	List<Apttus_Config2__AssetLineItem__c> aliSOList = [select id, Apttus_Config2__Description__c,
	Apttus_Config2__Quantity__c, Apttus_Config2__StartDate__c, Apttus_Config2__EndDate__c from Apttus_Config2__AssetLineItem__c
	where Apttus_Config2__AccountID__c = :accountID];

	lstAssetWrapper = new List<AssetWrapperClass>();
	
	for(Apttus_Config2__AssetLineItem__c aliSO : aliSOList) 
	{
		AssetWrapperClass objAssetWrapperClass = new AssetWrapperClass ();
		objAssetWrapperClass.AssetId = aliSO.ID;
		objAssetWrapperClass.ProductId = aliSO.Apttus_Config2__Description__c;
		objAssetWrapperClass.Quantity = aliSO.Apttus_Config2__Quantity__c;
		objAssetWrapperClass.StartDate = aliSO.Apttus_Config2__StartDate__c;
		objAssetWrapperClass.EndDate = aliSO.Apttus_Config2__EndDate__c;
		
		lstAssetWrapper.Add(objAssetWrapperClass);
	}
}
CODE


The terminate asset action enables you to terminate or cancel the selected asset items. The sample below enables you to terminate the asset and change its status by setting the end date as current date.

public void Terminate()
{
	//Declaring variable assetAction and assigning it a value Cancel
	string assetAction = 'Cancel';
	List<Apttus_CPQApi.CPQ.AssetActionDO> assetActDOList = new List<Apttus_CPQApi.CPQ.AssetActionDO>();

	//To terminate a selected Asset, set the end date as today 
	for(AssetWrapperClass objAssetWrapper : lstAssetWrapper) 
	{
		if(objAssetWrapper.selected)
		{
			Apttus_CPQApi.CPQ.AssetActionDO assetActDO = new Apttus_CPQApi.CPQ.AssetActionDO();
			assetActDO.AssetAction = assetAction;
			assetActDO.AssetLineItemId = objAssetWrapper.AssetId ;
			assetActDO.EndDate = Date.today().addMonths(0);
			assetActDO.Pending = true;
			assetActDO.Quantity = objAssetWrapper.Quantity;
			//assetActDO.StartDate = Date.today().addMonths(0);

			List<String> customFields = new List<String>();
			customFields.add('Apttus_Config2__Comments__c');
			customFields.add('Apttus_Config2__PricingStatus__c');
			
			assetActDO.CustomFields = customFields;
			
			Apttus_Config2__LineItem__c liSO = new Apttus_Config2__LineItem__c();
			liSO.Apttus_Config2__Comments__c = 'Comments Added my Modify Asset API Code';
			liSO.Apttus_Config2__PricingStatus__c = 'Complete';
			assetActDO.CustomData = liSO;            
			
			assetActDOList.add(assetActDO);
		}
	}
	//For a specific cart ID, invoke the API and modify the assets based on the terminate function above.
	Apttus_CPQApi.CPQ.ModifyAssetRequestDO modifyRequest = new Apttus_CPQApi.CPQ.ModifyAssetRequestDO();
	modifyRequest.CartId = cartID;
	modifyRequest.AssetActions = assetActDOList;
	
	Apttus_CPQApi.CPQ.ModifyAssetResponseDO modifyReponse = Apttus_CPQApi.CPQWebservice.modifyAsset(modifyRequest);
	
	List<Decimal> lineNumberList = modifyReponse.LineNumbers;
	
	List<Apttus_CPQApi.CPQ.AssetActionDO> assetList = modifyReponse.AssetActions;
	
	Boolean bIsPending = false;

	Integer iCounter = 0;
	
	while (iCounter < 1000) 
	{
		bIsPending = false;
		for(Apttus_CPQApi.CPQ.AssetActionDO objAsset: assetList)
		{
			if(objAsset.Pending == true)
			{
				bIsPending = true;
				break;
			}
		}
		//if asset action is pending execute the loop below
		if(bIsPending == true)
		{
			modifyReponse = Apttus_CPQApi.CPQWebservice.modifyAsset(modifyRequest);
			lineNumberList = modifyReponse.LineNumbers;
			assetList = modifyReponse.AssetActions;
		}
		else
		{
			break;
		}
		iCounter++;
	}
	
	bindAssets();
}

//Use the function below to bind the updated asset items.
public void bindAssets()
{
	List<Apttus_Config2__AssetLineItem__c> aliSOList = [select id, Apttus_Config2__Description__c,
	Apttus_Config2__Quantity__c, Apttus_Config2__StartDate__c, Apttus_Config2__EndDate__c from Apttus_Config2__AssetLineItem__c
	where Apttus_Config2__AccountID__c = :accountID];

	lstAssetWrapper = new List<AssetWrapperClass>();
	
	for(Apttus_Config2__AssetLineItem__c aliSO : aliSOList) 
	{
		AssetWrapperClass objAssetWrapperClass = new AssetWrapperClass ();
		objAssetWrapperClass.AssetId = aliSO.ID;
		objAssetWrapperClass.ProductId = aliSO.Apttus_Config2__Description__c;
		objAssetWrapperClass.Quantity = aliSO.Apttus_Config2__Quantity__c;
		objAssetWrapperClass.StartDate = aliSO.Apttus_Config2__StartDate__c;
		objAssetWrapperClass.EndDate = aliSO.Apttus_Config2__EndDate__c;
		
		lstAssetWrapper.Add(objAssetWrapperClass);
	}
}
CODE


The upgrade asset action enables you to update selected asset items. The sample below enables you to upgrade the asset. Using the sample below you can fetch the asset items using the getAssetsForSearchText API and upgrade the selected assetLineItems using AssetAction = Upgrade. You can upgrade the date and the quantity for an asset line item.

public static void processForUpgrade(ID cartId, ID accountId)
{
	//Declaration
	Set<ID> assetLineItemIds = new Set<ID>();

	Apttus_CPQApi.CPQ.AssetSearchResultDO result 
	 = Apttus_CPQApi.CPQWebService.getAssetsForSearchText(accountId, null, null);

	Apttus_CPQApi.CPQ.ModifyAssetRequestDO assetRequest = new Apttus_CPQApi.CPQ.ModifyAssetRequestDO();
	assetRequest.CartId = cartId;


	for (Apttus_Config2__AssetLineItem__c assetItemSO : result.AssetItems) 
	{
		Apttus_CPQApi.CPQ.AssetActionDO assetAction = new  Apttus_CPQApi.CPQ.AssetActionDO();
		assetAction.AssetAction = 'Upgrade';
		assetAction.AssetLineItemId = assetItemSO.Id;
		assetAction.Quantity = assetItemSO.Apttus_Config2__Quantity__c.intValue();
		assetAction.EndDate = Date.today();
		assetAction.Pending = true;
		assetLineItemIds.add(assetItemSO.Id);
		assetRequest.AssetActions.add(assetAction);            
	}

	Apttus_CPQApi.CPQ.ModifyAssetResponseDO assetResponse = Apttus_CPQApi.CPQWebService.modifyAsset(assetRequest);

	Set<Decimal> lineNumbers = new Set<Decimal>(assetResponse.LineNumbers);

	for (Apttus_Config2__LineItem__c lineSO : [Select Id, Apttus_Config2__AssetLineItemId__c from Apttus_Config2__LineItem__c Where Apttus_Config2__ConfigurationId__c = :cartId])
	{	

	} 
} 
CODE