Use identifier syntax in event subscriber arguments

Properties
LC0028 Warning Design Code Fix Ignore Obsolete

Event subscribers declare their target through parameters in the [EventSubscriber] attribute. Before Business Central 2023 wave 1 (BC22), these parameters required string literals — single-quoted names that the AL Language extension cannot resolve. With string literals, Go To Definition (F12) does not work on the event name, reference counts are missing, and hovering shows no tooltip. The subscriber is effectively invisible to VS Code’s navigation.

Since BC22, the same parameters accept identifier syntax. Removing the single quotes (or replacing them with double quotes for names that contain spaces) enables full VS Code navigation: Go To Definition, Go To References, tooltips, and CodeLens reference counts.

Identifier syntax enables Go To Definition, Go To References, tooltips, and CodeLens.

Example

codeunit 50100 MyCodeunit
{
    [EventSubscriber(ObjectType::Codeunit, Codeunit::"Sales-Post", 'OnAfterPostSalesDoc', '', false, false)] // Use identifier syntax in event subscriber arguments [LC0028]
    local procedure OnAfterPost(var SalesHeader: Record "Sales Header")
    begin
    end;
}

String syntax: the event name in single quotes has no navigability.

Replace the single-quoted string literal with an identifier — remove the quotes for simple names, or use double quotes for names that contain spaces:

codeunit 50100 MyCodeunit
{
    [EventSubscriber(ObjectType::Codeunit, Codeunit::"Sales-Post", OnAfterPostSalesDoc, '', false, false)]
    local procedure OnAfterPost(var SalesHeader: Record "Sales Header")
    begin
    end;
}

Identifier syntax: full VS Code navigation on the event name.

AL Language extension code action for converting string literals to identifiers.

See also