EventPublisher IsHandled by var (PC0011)

When publishing events with an IsHandled pattern, the IsHandled parameter must be declared as var so that subscribers can set it to true to indicate the event was handled.

A code fix is available for this diagnostic.

Example

The following event publisher has IsHandled without var:

codeunit 50100 MyCodeunit
{
    [IntegrationEvent(false, false)]
    local procedure OnBeforeProcess(IsHandled: Boolean) // EventPublisher IsHandled by var [PC0011]
    begin
    end;
}

To fix this, add the var keyword:

codeunit 50100 MyCodeunit
{
    [IntegrationEvent(false, false)]
    local procedure OnBeforeProcess(var IsHandled: Boolean)
    begin
    end;
}

See also

  • PC0010 - EventSubscriber var keyword
  • PC0023 - IsHandled parameter assignment