ALAppExtensions icon indicating copy to clipboard operation
ALAppExtensions copied to clipboard

[Event Request] Codeunit 6721 "Booking Manager" - Custom evaluation in CanHandleLine

Open krpr-navax opened this issue 1 year ago • 2 comments

Why do you need this change?

We would like to request a new integration event in the CanHandleLine procedure to allow for custom logic to determine whether a Sales Line should be processed in the Booking logic. As this check is executed for every single invoice line being posted, the overhead for bulk operations is incredibly high, even though the functionality is not in use by any of our customers. To improve performance during our bulk posting operations, the event will be subscribed using manual subscription to skip these costly executions for each line.

Describe the request

Object: codeunit 6721 "Booking Manager" Procedure: CanHandleLine

Current Code:

local procedure CanHandleLine(var SalesLine: Record "Sales Line"): Boolean
begin
    if SalesLine.IsTemporary then
        exit(false);

    if SalesLine."Document Type" <> SalesLine."Document Type"::Invoice then
        exit(false);

    exit(true);
end;

New Code:

[IntegrationEvent(false, false)]
local procedure OnCanHandleLine(var SalesLine: Record "Sales Line"; var HandleLine: Boolean; var IsHandled: Boolean)
begin
end;

local procedure CanHandleLine(var SalesLine: Record "Sales Line") HandleLine: Boolean
var
    IsHandled: Boolean;
begin
    if SalesLine.IsTemporary then
        exit(false);

    OnCanHandleLine(SalesLine, HandleLine, IsHandled);
    if IsHandled then
        exit;

    if SalesLine."Document Type" <> SalesLine."Document Type"::Invoice then
        exit(false);

    exit(true);
end;

Internal work item: AB#610409

krpr-navax avatar Oct 20 '25 07:10 krpr-navax

Hello @krpr-navax

Recently we announced that for every new IsHandled event request, author need to provide a response to several question (please check link)

We want to be sure that IsHandled event is the only option, as this kind of events is not the best approach due to several reasons (codebase harder to maintain, harder refactoring, fragile solutions, easily break other implementations...)

Please also check the explanation about when and how to use IsHandled events (link)

AleksandricMarko avatar Dec 02 '25 11:12 AleksandricMarko

No activities, will be closed

AleksandricMarko avatar Jan 15 '26 10:01 AleksandricMarko