4
Comparing the last releases of BC show, that the source code of the base app will be based on 2/3 EventPublisher and handle logic in near future.
It would be great, if a new attribute will be implemented that automatically creates an OnBeforeSomething, OnAfterSomething and OnSomething(..., Handled) with Handle pattern.

Example:
codeunit 50000 MyEventPublisher
{
// First true = OnBefore, second = On, third = OnAfter
[PublishEvents(true, true, true)]
local procedure MyFunction(SalesHeader: Record "Sales Header"; var ItemJnlLine: Record "Item Journal Line"): Boolean
begin
// my code
end;
}

Now all three events are generated from BC and can be used:
codeunit 50001 MyEventSubscriber
{
[EventSubscriber(ObjectType::Codeunit, Codeunit::MyEventPublisher, 'OnBeforeMyFunction', '', true, true)]
local procedure OnBeforeMyFunction(var SalesHeader: Record "Sales Header"; var ItemJnlLine: Record "Item Journal Line")
begin
end;

[EventSubscriber(ObjectType::Codeunit, Codeunit::MyEventPublisher, 'OnAfterMyFunction', '', true, true)]
local procedure OnAfterMyFunction(var SalesHeader: Record "Sales Header"; var ItemJnlLine: Record "Item Journal Line", var Result: Boolean)
begin
end;

[EventSubscriber(ObjectType::Codeunit, Codeunit::MyEventPublisher, 'OnMyFunction', '', true, true)]
local procedure OnMyFunction(var SalesHeader: Record "Sales Header"; var ItemJnlLine: Record "Item Journal Line", var Result: Boolean, var Handled: Boolean)
begin
end;
}
Category: Development
STATUS DETAILS
Needs Votes
Ideas Administrator

Thank you for this suggestion! Currently this is not on our roadmap. We are tracking this idea and if it gathers more votes and comments we will consider it in the future.

Best regards,
Business Central Team