AL icon indicating copy to clipboard operation
AL copied to clipboard

OnBeforeAction does not work in AL for actions with default names

Open cherabomb opened this issue 8 years ago • 2 comments

Edit with Server Version: NAV 2018 CU4 OnPremise, Version 11.0.21441.0, and AL Version 0.12.17720.

OnBeforeAction events do not fire when the event subscription is defined in AL on an Action with a default Name; I believe this to be a bug. To demonstrate, I defined 3 event handlers on Page 40 in an extension code unit:

[EventSubscriber(ObjectType::Page, Page::"Item Journal", 'OnBeforeActionEvent', '&Calculate Whse. Adjustment', false, false)]
local procedure TestOnBeforeActionEvent_WithoutName_AmpersandCaption(var Rec : Record "Item Journal Line")
begin
    Message('Hello world.');
end;
    
[EventSubscriber(ObjectType::Page, Page::"Item Journal", 'OnBeforeActionEvent', 'Test Report', false, false)]
local procedure TestOnBeforeActionEvent_WithoutName_CodeCaption(var Rec : Record "Item Journal Line")
begin
    Message('Hello world.');
end;
    
[EventSubscriber(ObjectType::Page, Page::"Item Journal", 'OnBeforeActionEvent', 'ItemTrackingLines', false, false)]
local procedure TestOnBeforeActionEvent_WithName(var Rec : Record "Item Journal Line")
begin
    Message('Hello world.');
end;

After publishing the extension including the code unit, I can see in the user interface that two of these subscribers do not work: grafik

I tried using the OnBeforeAction triggers in a page extension but they also did not fire.

Then I defined the exact same OnBeforeAction event subscribers in a C/AL code unit and they do work, but only because they address the actions with different names, as demonstrated in this screenshot: grafik

When I export the C/AL code unit to TXT, the actions are referenced using their default names. Unfortunately, these names are not available to me in Visual Studio Code.

Can this please be fixed? I cannot identify a workaround so it is a critical issue.

cherabomb avatar Jul 17 '18 08:07 cherabomb

Correct we also recently discovered this.

BartPermentier avatar Jul 19 '18 14:07 BartPermentier

This bug was fixed on Business Central. Please contact support to port the fix back to NAV 2018.

StanislawStempin avatar Aug 08 '18 07:08 StanislawStempin