# AppSourceCop Error AS0021
An argument in an event attribute cannot be changed to false.
## Description
An argument in an event attribute cannot be changed to false. This is not allowed because it may break dependent extensions that have subscribed to this event.
## Remarks
This rule verifies that events that are available from other extensions such as ../attributes/devenv-businessevent-attribute type events or ../attributes/devenv-integrationevent-attribute type events do not stop exposing their sender or their global variables.
This does not apply to ../attributes/devenv-internalevent-attribute type events as they are not exposed to dependent extensions.
## Code examples triggering the rule
### Example 1 - A business type event stops exposing its sender
Version 1.0 of the extension:
```al
codeunit 50100 MyCodeunit
{
    [BusinessEvent(true)]
    procedure MyEvent()
    begin
    end;
}
```
Version 2.0 of the extension:
```al
codeunit 50100 MyCodeunit
{
    [BusinessEvent(false)]
    procedure MyEvent()
    begin
    end;
}
```
In the newer version, the sender exposed by MyEvent is not accessible to subscribers anymore. If a dependent extension relies on it, this will lead to a compilation error similar to `The member referenced by event subscriber 'MyProcedure' parameter 'sender' is not found (AL0282)`.
For example, the following extension compiles when depending on version 1.0, but fails to compile with version 2.0:
```al
codeunit 50120 AnotherCodeunit
{
    [EventSubscriber(ObjectType::Codeunit, Codeunit::MyCodeunit, 'MyEvent', '', true, true)]
    local procedure MyProcedure(sender: Codeunit MyCodeunit)
    begin
        // Subscriber logic
    end;
}

```
### Example 2 - An integration type event stops exposing global variables
Version 1.0 of the extension:
```al
codeunit 50100 MyCodeunit
{
    [IntegrationEvent(true, true)]
    procedure MyEvent()
    begin
    end;

    var
        myGlobalVariable: Integer;
}
```
Version 2.0 of the extension:
```al
codeunit 50100 MyCodeunit
{
    [IntegrationEvent(true, false)]
    procedure MyEvent()
    begin
    end;

    var
        myGlobalVariable: Integer;
}
```
In the newer version, the global variables exposed by MyEvent are not accessible to subscribers anymore. If a dependent extension relies on global variables, this will lead to a compilation error similar to `The member referenced by event subscriber 'MyProcedure' parameter 'myGlobalVariable' is not found (AL0282)`.
For example, the following extension compiles when depending on version 1.0, but fails to compile with version 2.0:
```al
codeunit 50120 AnotherCodeunit
{
    [EventSubscriber(ObjectType::Codeunit, Codeunit::MyCodeunit, 'MyEvent', '', true, true)]
    local procedure MyProcedure(myGlobalVariable: Integer)
    begin
        // Subscriber logic
    end;
}
```
## Code examples not triggering the rule
### Example 1 - An event does not change over time
Version 1.0 of the extension:
```al
codeunit 50100 MyCodeunit
{
    [BusinessEvent(false)]
    procedure MyEvent()
    begin
    end;
}
```
Version 2.0 of the extension:
```al
codeunit 50100 MyCodeunit
{
    [BusinessEvent(false)]
    procedure MyEvent()
    begin
    end;
}
```
The event remains the same from one version to the other.
### Example 2 - An event starts exposing its sender
Version 1.0 of the extension:
```al
codeunit 50100 MyCodeunit
{
    [BusinessEvent(false)]
    procedure MyEvent()
    begin
    end;
}
```
Version 2.0 of the extension:
```al
codeunit 50100 MyCodeunit
{
    [BusinessEvent(true)]
    procedure MyEvent()
    begin
    end;
}
```
In the newer version of the extension, the sender becomes exposed through the business type event.
## Related information
AppSourceCop Analyzer<appsourcecop>
Get Started with AL<../devenv-get-started>
Developing Extensions<../devenv-dev-overview>

Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/analyzers/appsourcecop-as0021, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact. https://jonas-paprotka.de/docs/dev-itpro/developer/analyzers/appsourcecop-as0021/
