Adjustment Line Item Callback allows you to write custom logic to auto-create or auto-delete adjustments for the line items. For example, once a product is added to cart, some adjustments need to be auto-included based on the account contract or other terms. In such a case, you can use Adjustment Line Item callback to automate this process. When you apply an adjustment on a proposal, the callback will overwrite manual adjustments.

Agents can change the discounts anytime and that will not reflect on the cart. Agents cannot do this manually per line item, so we have given the custom page for them to manage the discounts.

To use the Adjustment Line Item Callback you must create a custom Apex class that implements the Apttus_Config2.CustomClass.IAdjustmentLineItemCallback2 interface and register the custom apex class with Adjustment Line Item Callback Class. You must write your custom logic in the custom apex class.

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

createAdjustmentLineItems()List createAdjustmentLineItems(Apttus_Config2.LineItem)You can use this method to create adjustments for the given parent line item
finish()void finish()This the last method that is executed after the callback is invoked.
start()void start(Apttus_Config2.ProductConfiguration)This is the first method that is executed when the callback is invoked.
beforeSaveAdjustmentLineItems()Boolean beforeSaveAdjustmentLineItems(Apttus_Config2.LineItem, List)You can use this method to apply custom logic after the user adjustments are finished and before the changes are saved.


The given code example implements createAdjustmentLineItems() method to create new adjustment line items using the IAdjustmentLineItemCallback2 interface.

global with sharing class SampleAdjustmentCallback
                          implements Apttus_Config2.CustomClass.IAdjustmentLineItemCallback,
                                      Apttus_Config2.CustomClass.IAdjustmentLineItemCallback2 {
     * Callback at the beginning of the adjustment call.
     * Use the start method to initialize state
     * @param cart the cart object
    global void start(Apttus_Config2.ProductConfiguration cart) {
        // do nothing  
     * Callback to create adjustments for the given parent line item
     * @param parentItem the parent line item associated with the adjustments
     * @return the list of adjustment line item sobjects
    global List<Apttus_Config2.AdjustmentLineItem__c> createAdjustmentLineItems (
                                                                     Apttus_Config2.LineItem parentItem) {
        List<Apttus_Config2.AdjustmentLineItem__c> adjItems = new List<Apttus_Config2.AdjustmentLineItem__c>();
        // test data
        if (Test.isRunningTest() == true && SystemUtil.isMultiAdjustmentEnabled() == true) {
            // get the parent item sobject
            Apttus_Config2__LineItem__c parentItemSO = parentItem.getLineItemSO();
            // create a line item adjustment
            //AdjustmentLineItem__c adjItemSO = new AdjustmentLineItem__c(LineItemId__c = parentItemSO.Id);
            Apttus_Config2__AdjustmentLineItem__c adjItemSO = new Apttus_Config2__AdjustmentLineItem__c();
            // line number
            adjItemSO.LineNumber__c = 1;
            // line type
            adjItemSO.LineType__c = 'Manual';
            // modifiable
            adjItemSO.IsModifiable__c = true;
            // adjustment type
            adjItemSO.AdjustmentType__c = '% Discount';
            // adjustment amount
            adjItemSO.AdjustmentAmount__c = 10;
            // adjustment applies to
            adjItemSO.AdjustmentAppliesTo__c ='Starting Price';
        return adjItems;
     * Callback before the adjustment line items are saved after user changes
     * @param parentItem the parent line item associated with the adjustments
     * @param adjItems the list of adjustment line items associated with the save operation
     * @return <code>true</code> if adjustment line items were modified by the callback, 
     * <code>false</code> otherwise
    global Boolean beforeSaveAdjustmentLineItems(Apttus_Config2__LineItem parentItem, 
                                                 List< Apttus_Config2__AdjustmentLineItem__c> adjItems) {
        return false;
     * Callback after all batches of adjustment line items are processed
     * Use the finish method to release state
    global void finish() {
        // do nothing