Validation Callback Class
Validation Callback provides a mechanism to implement custom validations on the line items in the cart. Validations are any constraints you define on the line item to restrict the selection of that line item based on any condition or criteria. When you define validations, CPQ checks if the condition or the criteria is satisfied and displays an error message accordingly. For example, you can validate if the Quantity field for any product is negative and prevent the sales rep from finalizing the cart.
- Line items in the cart
- Price Ramps
To use the Validation Callback you must create a custom Apex class that implements the Apttus_Config2.CustomClass.IValidationCallback3 interface and register the custom apex class with Validation Callback Class. You must write your custom logic in the custom apex class.
The following methods are available in the Apttus_Config2.CustomClass.IValidationCallback3 interface:
Method | Signature | Description |
---|---|---|
validateCart() | Apttus_Config2.CustomClass.ValidationResult validateCart (Apttus_Config2.CustomClass.ActionParams, Apttus_Config2.ProductConfiguration) | You can use this method to apply validation on line items in the cart. This method is invoked when the Sales rep performs the following actions:
|
validateRampLineItems() | Apttus_Config2.CustomClass.ValidationResult validateRampLineItems (Apttus_Config2.CustomClass.ActionParams, Apttus_Config2.ProductConfiguration, List) | You can use this method to apply validation on the ramp line items in a Price Ramp. This method is invoked when the Sales rep performs the following actions:
|
The following are examples of the custom logic you can implement using Validation example
Example
You can use validateCart() apply the following validations:
- Check if the Duration for any product is null.
- Check if the value in the Adjustment Amount field is negative.
The given code example implements two methods of IValidationCallback3 interface. The code sample implements the abovementioned validation using the method validateCart().