Conga Product Documentation

Welcome to the new doc site. Some of your old bookmarks will no longer work. Please use the search bar to find your desired topic.

download

IActionCallback3 Interface

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:

Method

Signature

Description

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

Name

Type

Description

BundleLineItemIds

List

The list IDs of line items.

CartId

Id

The ID of the configuration

Response Parameters: Apttus_Config2.CustomClass.ActionCallbackResponse

Name

Type

Description

errorMessages

List<String>

List of error messages if they occur.

IsSuccess

Boolean

Indicates whether the action was successful.

Example 1:

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(); } }

Example 2:

The sample code below uses beforeCopyBundleLineItems() to validate line items based on custom logic. You can clone the line only if:

  • The number of items to be cloned does not exceed the defined limit.
  • The product is active.

You can add more conditions as needed and display relevant error messages based on your business requirements.

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(); result.isSuccess= true; 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__PricingStatus__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; } //beforeCopyBundleLineItems public static final Integer MAX_LI_TO_CLONE = 5; public static final String CLONE_LIMIT_EXCEED_ERROR_MESSAGE = 'Clone of more than \''+ MAX_LI_TO_CLONE + '\' line items not supported. Please select fewer line items to clone'; public static final String INACTIVE_PRODUCT = 'Product is not active'; global static Apttus_Config2.CustomClass.ActionCallbackResponse beforeCopyBundleLineItems(Apttus_Config2.CustomClass.ActionCallbackRequest callbackReq) { Apttus_Config2.CustomClass.ActionCallbackResponse result = new Apttus_Config2.CustomClass.ActionCallbackResponse(); result.isSuccess= true; List<Id> lstLIToClone = callbackReq.BundleLineItemIds; // check the clone lineitems limit. if(lstLIToClone != null && lstLIToClone.size() > MAX_LI_TO_CLONE) { result.isSuccess= false; result.errorMessages.add(CLONE_LIMIT_EXCEED_ERROR_MESSAGE); System.debug(LoggingLevel.ERROR, CLONE_LIMIT_EXCEED_ERROR_MESSAGE); return result; } for (Apttus_Config2__LineItem__c oLI : [ SELECT Apttus_Config2__CollaborationRequestId__r.Apttus_Config2__Status__c, Apttus_Config2__ProductId__r.Apttus_Config2__Version__c, Apttus_Config2__ProductId__r.IsActive, Apttus_Config2__PricingStatus__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 :lstLIToClone]) { // check the product is active or not. //similar way we can check for other conditions based on the requirement and add the respective error message. if(!oLI.Apttus_Config2__ProductId__r.IsActive){ result.isSuccess= false; result.errorMessages.add(INACTIVE_PRODUCT); System.debug(LoggingLevel.ERROR, INACTIVE_PRODUCT); break; } } return result; } }