Product Attribute Callback allows you to set the default value of the product attributes based on custom logic at run-time. The callback is invoked when you open the Configuration page to select attributes and options for the products.

To use the Product Attribute Callback you must create a custom Apex class that implements the Apttus_Config2.CustomClass.IProductAttributeCallback interface and register the custom apex class with Product Attribute Callback Class. You must write your custom logic in the custom apex class.

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

finish()void finish()This the last method that is executed after the callback is invoked.
setDefaults()void setDefaults(Apttus_Config2.LineItem, Apttus_Config2__ProductAttributeValue__c)You can use this method to set the default value of product attributes. This method is invoked only when you enable Has Attribute field for the product.
start()void start(Apttus_Config2.ProductConfiguration)

This is the first method that is executed when the callback is invoked. 

You must enable Has Attribute field in product details. Otherwise, when the callback is invoked, only the start() and finish() methods are called and the callback does not set the default values for product attributes.


In the following example, the Product Attribute Callback sets the default attributes of the Car object.

* Product Attribute Call Back example.
* Configure a proposal in test org, which has PriceList = 'CPQ 202'
* Configure Product = 'Car',
* and verify the default attributes
* prodAttr.Exterior_Color__c = 'Silver'
* prodAttr.Leather_Color__c = 'Brown'
* prodAttr.Inlay__c = 'Walnut'
* prodAttr.Fuel_Type__c = 'Diesel'
* prodAttr.Fuel_Badge__c = 'No'
global with sharing class SampleProductAttributeCallback implements Apttus_Config2.CustomClass.IProductAttributeCallback {
    Id accountId;
    global void start(Apttus_Config2.ProductConfiguration config) {
        system.debug('***ProdAttrCallBack > start() > ' + config);
    global void setDefaults(Apttus_Config2.LineItem lineItem, Apttus_Config2__ProductAttributeValue__c prodAttr) {
        system.debug('***ProdAttrCallBack > setDefaults() > prodAttr:' + prodAttr + ';<>; lineItem:' + lineItem);
        // lineItem is a wrapper class to the lineItem class which we use in product configuration.
        // Take line Item from this wrapper class.
        Apttus_Config2__LineItem__c prodLineItem = lineItem.getLineItemSO();
        system.debug('***ProdAttrCallBack > Product Selected: ' + prodLineItem.Apttus_Config2__Description__c);
        if(prodLineItem.Apttus_Config2__Description__c == '(Demo) Car') {
            prodAttr.Exterior_Color__c = 'Silver';
            prodAttr.Leather_Color__c = 'Brown';
            prodAttr.Inlay__c = 'Walnut';
            prodAttr.Fuel_Type__c = 'Diesel';
            prodAttr.Fuel_Badge__c = 'No';
        if(prodLineItem.Apttus_Config2__Description__c == 'Internet Service') {
            prodAttr.Internet_Speed__c = '25 Mbps';
    global void finish() {
        system.debug('***ProdAttrCallBack > finish()');