Customization Using Callbacks
Callback methods provide a mechanism to execute custom actions at different stages in the contract management process.
You can implement callback methods using one or more of the following options:
- Using Telemetry Traces: 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.
- Using LogHelper: 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:
- Get the Log Helper.
- Log any of the supported level log message for example: logHelper.LogInformation or logHelper.LogDebug
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);
- Using DataHelper: 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.
- Using HttpHelper: 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.
You can prevent long-running or stalled processes from impacting system performance. To do so, add CancellationToken parameter in the callback methods to gracefully terminate custom code execution when a configured timeout threshold has been reached. The threshold is defined in the Execution Abort Timeout field (in milliseconds) within Custom Code Settings in the Admin Console.