Event subscriber var keyword mismatch

Properties
PC0010 Warning Design Code Fix Ignore Obsolete

When an event publisher declares a parameter as var, it passes that parameter by reference. If a subscriber omits var on the matching parameter, it receives a copy instead.

Any changes the subscriber makes to the copy are silently discarded. The publisher and all subsequent subscribers see the original, unmodified value. For a Record parameter like "Sales Header", field assignments or record modifications inside the subscriber have no effect on the record the caller is working with.

Add the var keyword to the subscriber parameter to match the publisher declaration.

Example

The publisher declares SalesHeader as var, but the subscriber omits it:

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

Add var 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;
}

Code fix

Adds the var keyword to subscriber parameters that the publisher defines as var.

See also