EventSubscriber var keyword (PC0010)

Parameters in event subscriber procedures should use the var keyword when the event publisher declares them as var. Mismatching the var keyword can lead to unexpected behavior where modifications to parameters are not propagated correctly.

A code fix is available for this diagnostic.

Example

The following event subscriber is missing the var keyword:

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

To fix this, add the var keyword to match the publisher:

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

See also

  • PC0011 - EventPublisher IsHandled by var