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.

Display Action Callback Class

Display Action Callback provides you a mechanism to disable any of the action buttons on the cart. Following are few examples of custom buttons that you can disable:

  • Abandon
  • Approvals
  • Generate
  • Quick Save

To use the Display Action Callback you must create a custom C# class that implements the IDisplayActionCallback interface and register the custom C# class with Display Action Callback Class. You must write your custom logic in the custom C# class.

Primary Action support is introduced enabling you to define the primary action (Custom or OOTB) as per the business needs.

Note:

The error handling for the display actions has been implemented to ensure better visibility and control during the cart life cycle. When a callback or API returns an error, the user is now notified with the default display actions and the error message, indicating the accurate error.

The following method is available in the IDisplayActionCallback interface:

Method

Signature

Description

ExecuteDisplayAction()

Task ExecuteDisplayAction(IActionRequest actionRequest, CancellationToken cancellationToken)

You can use this method to execute display action.

CancellationToken has been introduced in custom code developed within the Conga Advantage Platform. If you are still using the older approach, you must mark those legacy methods as obsolete. This means applying the [Obsolete] attribute to methods that do not support tokens. For example: [Obsolete("Use version with CancellationToken")]. For more information, see CancellationToken Implementation Guidelines.

Following is an usecase of ExecuteDisplayAction method.

public async Task ExecuteDisplayAction(IActionRequest request,CancellationToken cancellationToken)
{
    ThrowIfCancellationRequested(cancellationToken);
    var logHelper = GetLogHelper();
    try
    {
        logHelper?.LogInformation($"DisplayActionCallback.ExecuteDisplayAction Started");
        var cart = request.GetCartContext().GetCart();
        string cartStatus = cart.GetEntity().ApprovalStatus;
        var actionsInfo = request.GetDisplayActionInfo();
        if (actionsInfo != null)
        {
            foreach (var action in actionsInfo)
            {
                if (action.ActionName == Constants.ACTION_SUBMIT_FOR_APPROVAL && cartStatus == "Approval Required")
                {
                    action.IsEnabled = true;
                    action.IsPrimaryAction = true;
                }
            }
        }
        logHelper?.LogInformation($"DisplayActionCallback.ExecuteDisplayAction Ended");
    }
    catch (Exception ex)
    {
        logHelper?.LogError("Exception ex:" + ex.Message + " stack trace:" + ex.StackTrace);
    }
    await Task.CompletedTask;
}