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.

Validation Callback applies validation on the following aspects in the configuration: ​

  • Entire cart

  • Line items in the cart

  • Price Ramps​

To use the Validation Callback you must create a custom C# that implements the IValidationCallback interface and register the custom C# with Validation Callback Class. You must write your custom logic in the custom C# language.

The following methods are available in the IValidationCallback interface:

MethodSignatureDescription
BeforePricingValidationAsyncBeforePricingValidationAsync(IActionRequest request)This extension point is utilized for creating pre-price validation callbacks.
FinalizeValidationAsyncFinalizeValidationAsync(IActionRequest request)This hook point is used to write validation callback code for finalize event.
OnCartValidationAsyncOnCartValidationAsync(IActionRequest actionRequest)This is generic method for validation callback.

The following is an example of the custom logic you can implement using Validation example.

Example

The given code example implements the method of IValidationCallback interface. 

using Conga.Revenue.Common.Callback.Messages;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Conga.Revenue.Common.Callback
{
    public interface IValidationCallback
    {
        /// <summary>
        /// This extension point is used to write prepricing validation callback
        /// </summary>
        /// <param name="actionRequest">This will have cart context where lines are there.</param>
        public Task BeforePricingValidationAsync(IActionRequest actionRequest);

        /// <summary>
        /// This hookpoint is used to write validation callback code for finalize event
        /// </summary>
        /// <param name="actionRequest"></param>
        /// <returns></returns>
        public Task FinalizeValidationAsync(IActionRequest actionRequest);

        /// <summary>
        /// This is generic method for validation callback
        /// </summary>
        /// <param name="actionRequest"></param>
        /// <returns></returns>
        public Task OnCartValidationAsync(IActionRequest actionRequest);

    }
}
CODE