Callback methods provide a mechanism to execute custom actions at different stages in the contract management process. The following methods are available for different objects:

Object NameMethodSignaturePurpose
AgreementAfterCreateAsync()AfterCreateAsync( )This method executes custom logic after creating a contract.
AgreementAfterStoreExecutedDocumentAsync()AfterStoreExecutedDocumentAsync(IContractLifecycleDocumentRequest contractLifecycleDocumentRequest)This method executes custom logic after the executed document is uploaded to the contract record for activation and further lifecycle stages, such as amendment or renewal.
AgreementAfterImportOfflineDocumentAsync()AfterImportOfflineDocumentAsync(IContractLifecycleDocumentRequest contractLifecycleDocumentRequest)This method executes custom logic after importing an offline document to the contract record.
AgreementAfterCreateOfflineDocumentAsync()AfterCreateOfflineDocumentAsync(IContractLifecycleDocumentRequest contractLifecycleDocumentRequest)This method executes custom logic after creating an offline contract from a third-party paper through Conga X-author.
AgreementAfterActivateSync()AfterActivateSync(IContractLifecycleRequest contractsLifecycleRequest)This method executes custom logic after activating a contract.
AgreementAfterAmendAsync()AfterAmendAsync(IContractLifecycleRequest originalContractsLifecycleRequest, IContractLifecycleRequest amendmentContractsLifecycleRequest)This method executes custom logic after amending a contract.
AgreementAfterRenewAsync()AfterRenewAsync(IContractLifecycleRequest originalContractsLifecycleRequest, IContractLifecycleRequest renewalContractsLifecycleRequest)This method executes custom logic after renewing a contract.
AgreementAfterCancelAsync()AfterCancelAsync(IContractLifecycleRequest contractsLifecycleRequest)This method executes a custom logic after canceling a contract.
AgreementAfterExpireAsync()AfterExpireAsync(IContractLifecycleRequest contractsLifecycleRequest)This method executes a custom logic after a contract expires.
AgreementAfterTerminateAsync()AfterTerminateAsync(IContractLifecycleRequest contractsLifecycleRequest)This method executes a custom logic after terminating a contract.
AgreementAfterCloneAsync()AfterCloneAsync(IContractLifecycleRequest originalContractsLifecycleRequest, IContractLifecycleRequest cloneContractsLifecycleRequest)This method executes a custom logic after cloning a contract.
AgreementAfterUpdateAsync()AfterUpdateAsync(ILifecycleActionCallbackRequest lifecycleActionCallbackRequest)This method executes a custom logic after editing a contract.
AgreementAfterDeleteAsync()AfterDeleteAsync(ILifecycleActionCallbackRequest lifecycleActionCallbackRequest)This method executes a custom logic after deleting a contract.
AgreementBeforeCreateAsync()BeforeCreateAsync(IBeforeLifecycleActionCallbackRequest beforeLifecycleActionCallbackRequest)This method executes a custom logic before creating a contract.
AgreementBeforeUpdateAsync()BeforeUpdateAsync(IBeforeLifecycleActionCallbackRequest beforeLifecycleActionCallbackRequest)This method executes a custom logic before updating a contract.
AgreementBeforeDeleteAsync()BeforeDeleteAsync(ILifecycleActionCallbackRequest lifecycleActionCallbackRequest)This method executes a custom logic before delete a contract.


You can implement callback methods using one or more of the following options:

Telemetry Traces allows you to trace complex operations from the custom code. You can add it as a child span of the custom code execution operation. The traces are available in Grafana tempo.

You can use LogHelper to log required information from the custom code. The log information is available in Grafana traces at runtime. At the time of authoring, these logs are available under console output tab in authoring UI callback edit screen.

To write logs in callbacks,

  1. Get the Log Helper

  2. Log any of the supported level log message for example: logHelper.LogInformation or logHelper.LogDebug etc

The following methods are available in LogHelper class:

  • void LogCritical(string message);
  • void LogDebug(string message);
  • void LogDebug(object obj);
  • void LogError(string message);
  • void LogInformation(string message);
  • void LogTrace(string message);
  • void LogWarning(string message);

DataHelper allows querying the object data. It can also be used to add, update, delete object records, which can be custom or product objects, from custom code.

HttpHelper enables HTTP communication from custom code to third-party services. External service endpoints must be in the Trusted-API configuration to allow external communication from HttpHelper.


Example 1:

The below code uses the DataHelper and adds telemetry log information to the contract's Description field on contract creation.

using System;
using System.Linq;
using Conga.Platform.Extensibility.CustomCode.Library;
using System.Collections.Generic;
using System.Threading.Tasks;
using Conga.Contracts.Common.Callback;
using Conga.Contracts.Common.Callback.Messages;
using CallbackTest;

namespace CallbackTest
{
    /// <summary>
    /// Contracts lifecycle Callback
    /// </summary>
    public class TestContractLifecycleCallback : CodeExtensibility, IContractLifecycleCallback
    {
        public async Task AfterCreateAsync(ILifecycleActionCallbackRequest lifecycleActionCallbackRequest)
        {
            var traceHelper = GetTelemetryHelper();
            using var span = traceHelper.StartActiveSpan($"{nameof(TestContractLifecycleCallback)}.{nameof(this.AfterActivateAsync)}");
            span?.AddLog($"AfterCreateAsync {lifecycleActionCallbackRequest.ContractId}");
			var dataHelper = GetDataHelper();
            Dictionary<string, object> contract = new()
                {
                    {"Id", lifecycleActionCallbackRequest.ContractId },
                    {"Description", "Contract is created Successfully and ID= " + lifecycleActionCallbackRequest.ContractId }
                };
            await dataHelper.UpdateAsync("Agreement", contract);
            await Task.CompletedTask;
        }
    }
}
CODE


Example 2:

The below code adds telemetry log information to check if RecordType is "CAF".  If RecordType is CAF, then AgreementCategory cannot be null. If AgreementCategory is null, then CLM shows an AgreementCategory is required. message. 

using System;
using System.Linq;
using Conga.Platform.Extensibility.CustomCode.Library;
using System.Collections.Generic;
using System.Threading.Tasks;
using Conga.Contracts.Common.Callback;
using Conga.Contracts.Common.Callback.Messages;

namespace CallbackTest
{
    /// <summary>
    /// Contracts lifecycle Callback
    /// </summary>
    public class TestContractLifecycleCallback : CodeExtensibility, IContractLifecycleCallback
    {
        public async Task<ICallbackResult> BeforeCreateAsync(IBeforeLifecycleActionCallbackRequest beforeLifecycleActionCallbackRequest)
        {
            bool success = true;
            string message = "";
            var traceHelper = GetTelemetryHelper();
            using var span = traceHelper.StartActiveSpan($"{nameof(TestContractLifecycleCallback)}.{nameof(this.BeforeCreateAsync)}");
            Dictionary<string, object> contract = beforeLifecycleActionCallbackRequest.Contract;
            if (contract != null &&
           contract.TryGetValue("RecordType", out var RecordType) &&
           RecordType?.ToString() == "RecordType1" &&
           (!contract.TryGetValue("AgreementCategory", out var AgreementCategory) || AgreementCategory == null))
            {
                success = false;
                message = "AgreementCategory is required.";
            }
            ICallbackResult result = new CallbackResult(success, message);
            return await Task.FromResult(result);
        }
    }
}
CODE


Example 3:

var logHelper = GetLogHelper();
logHelper.LogInformation("This is sample info message");
CODE