IActionCallback3 class provides a mechanism to apply custom actions before delete and copy actions on bundles.

The following methods are available in the Apttus_Config2.CustomClass.IActionCallback3 interface:

MethodSignatureDescription
beforeCopyBundleLineItems() Apttus_Config2.CustomClass.ActionCallbackResponse beforeCopyBundleLineItems(Apttus_Config2.CustomClass.ActionCallbackRequest)

You can use this method to perform tasks to be executed before a bundle is copied. This method is invoked when the Sales Rep Clones bundle or standalone product.

beforeDeleteBundleLineItems() Apttus_Config2.CustomClass.ActionCallbackResponse beforeDeleteBundleLineItems(Apttus_Config2.CustomClass.ActionCallbackRequest)

You can use this method to perform tasks to be executed before performing the following actions:

  • Abandoning the configuration
  • creating, updating, and deleting line items
Request Parameters: Apttus_Config2.CustomClass.ActionCallbackRequest
NameTypeDescription
BundleLineItemIdsListThe list IDs of line items.
CartIdIdThe ID of the configuration
Response Parameters: Apttus_Config2.CustomClass.ActionCallbackResponse
NameTypeDescription
errorMessagesList<String>List of error messages if they occur.
IsSuccessBooleanIndicates whether the action was successful.

Example

The sample code below allows you to use beforeDeleteBundleLineItems() to validate the line items based on custom logic written in the method. You can allow the deletion of a line only when the following conditions are fulfilled:

  • The number of line items to be deleted is not more than the limit defined in the code.
  • The line items are not read-only and any approval request is not pending.
  • The line items are not in collaboration.
global with sharing class APTS_ActionCallback3 implements Apttus_Config2.CustomClass.IActionCallback3 
{
    private static final String strEMPTY = '';
    public static final Integer MAX_LI_TO_DELETE = 2;
    public static final String BUSINESS_OBJECT_TYPE_PROPOSAL = 'Proposal';
    public static final String PRODCONFIG_STATUS_PENDING_APPROVAL = 'Pending Approval';
    public static final String COLLAB_STATUS_COMPLETED = 'Completed';
    public static final String COLLAB_STATUS_ACCEPTED = 'Accepted';
    public static final String DEL_LIMIT_EXCEED_ERROR_MESSAGE = 'Deletion of more than \''+ 
                                                                 MAX_LI_TO_DELETE +
                                                                 '\' line items not supported. Please select fewer line items to delete';

    public static final String PARENT_UC_ERROR_MESSAGE = 'Parent cart under collaboration, can not delete';

    global static Apttus_Config2.CustomClass.ActionCallbackResponse beforeDeleteBundleLineItems(Apttus_Config2.CustomClass.ActionCallbackRequest CallBackReq)
	{
        Apttus_Config2.CustomClass.ActionCallbackResponse result = new Apttus_Config2.CustomClass.ActionCallbackResponse();
        List<Id> lstLIToDel = CallBackReq.BundleLineItemIds;

        // check the deletion limit.
        if(lstLIToDel != null && lstLIToDel.size() > MAX_LI_TO_DELETE)
		{
            result.isSuccess= false;
            result.errorMessages.add(DEL_LIMIT_EXCEED_ERROR_MESSAGE);
            System.debug(LoggingLevel.ERROR, DEL_LIMIT_EXCEED_ERROR_MESSAGE);
            return result;
        }
        
        // Check for collaboration status.
        String collabRequestStatus;
        Boolean isCollabComplete;
    
        for (Apttus_Config2__LineItem__c oLI : [
            SELECT Apttus_Config2__CollaborationRequestId__r.Apttus_Config2__Status__c,
                   Apttus_Config2__CollaborationRequestId__c,
                   Apttus_Config2__ConfigurationId__r.Apttus_Config2__Status__c, 
                   Apttus_Config2__ConfigurationId__r.Apttus_Config2__BusinessObjectType__c, 
                   Apttus_Config2__IsReadOnly__c
            FROM Apttus_Config2__LineItem__c 
            WHERE Id IN :lstLIToDel]) {

            collabRequestStatus = (oLI.Apttus_Config2__CollaborationRequestId__c != NULL) ? 
                                    oLI.Apttus_Config2__CollaborationRequestId__r.Apttus_Config2__Status__c :
                                    strEMPTY ;
            isCollabComplete = (String.isNotBlank(collabRequestStatus) && 
                               !(collabRequestStatus == COLLAB_STATUS_COMPLETED || COLLAB_STATUS_ACCEPTED == collabRequestStatus)) ? 
                                    true : 
                                    false;
            
            if(BUSINESS_OBJECT_TYPE_PROPOSAL == oLI.Apttus_Config2__ConfigurationId__r.Apttus_Config2__BusinessObjectType__c
               && (oLI.Apttus_Config2__IsReadOnly__c || 
                   isCollabComplete || 
                   PRODCONFIG_STATUS_PENDING_APPROVAL == oLI.Apttus_Config2__ConfigurationId__r.Apttus_Config2__Status__c)){

                result.isSuccess= false;
                result.errorMessages.add(PARENT_UC_ERROR_MESSAGE);
                System.debug(LoggingLevel.ERROR, PARENT_UC_ERROR_MESSAGE);
                break;
            }
        }
        return result;
    }

    global static Apttus_Config2.CustomClass.ActionCallbackResponse beforeCopyBundleLineItems(Apttus_Config2.CustomClass.ActionCallbackRequest callbackReq)
	{
            return new Apttus_Config2.CustomClass.ActionCallbackResponse();
    }

}
CODE