{"title":"AppSourceCop Error AS0020","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/analyzers/appsourcecop-as0020/","by":"JOP-AL","license":"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-as0020, 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.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/analyzers/appsourcecop-as0020","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"The event attribute type cannot be changed because it might break dependent extensions.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"AppSourceCop Error AS0020","slug":"appsourcecop-error-as0020","at":0,"chars":6400},{"level":2,"title":"Description","slug":"description","at":66,"chars":103},{"level":2,"title":"Remarks","slug":"remarks","at":169,"chars":1943},{"level":3,"title":"Converting business events","slug":"converting-business-events","at":659,"chars":647},{"level":3,"title":"Converting integration events","slug":"converting-integration-events","at":1306,"chars":630},{"level":3,"title":"Converting internal events","slug":"converting-internal-events","at":1936,"chars":176},{"level":2,"title":"Examples of valid event type conversion","slug":"examples-of-valid-event-type-conversion","at":2112,"chars":952},{"level":3,"title":"Example 1 - Converting an integration type event to a business type event","slug":"example-1---converting-an-integration-type-event-to-a-business-type-event","at":2155,"chars":490},{"level":3,"title":"Example 2 - Converting an internal event to an integration event","slug":"example-2---converting-an-internal-event-to-an-integration-event","at":2645,"chars":419},{"level":2,"title":"Examples of nonvalid event type conversions","slug":"examples-of-nonvalid-event-type-conversions","at":3064,"chars":3189},{"level":3,"title":"Example 1 - Conversion of a business type event to an internal type event","slug":"example-1---conversion-of-a-business-type-event-to-an-internal-type-event","at":3111,"chars":941},{"level":3,"title":"Example 2 - Conversion of an integration type event that exposed variables to a business type event","slug":"example-2---conversion-of-an-integration-type-event-that-exposed-variables-to-a-business-type-event","at":4052,"chars":1156},{"level":3,"title":"Example 3 - Conversion of an integration type event to a business type event that stops exposing its sender","slug":"example-3---conversion-of-an-integration-type-event-to-a-business-type-event-that-stops-exposing-its-sender","at":5208,"chars":1045},{"level":2,"title":"Related information","slug":"related-information","at":6253,"chars":147}],"text":"# AppSourceCop Error AS0020\nThe type of events cannot be changed.\n## Description\nThe event attribute type cannot be changed because it might break dependent extensions.\n## Remarks\nAs part of your extension, you can ../devenv-publishing-events that will be available for other extensions to subscribe to<../devenv-subscribing-to-events>.\nIn AL, you can define events of the following types:\n ../attributes/devenv-businessevent-attribute\n ../attributes/devenv-integrationevent-attribute\n ../attributes/devenv-internalevent-attribute\nThis rule verifies that the conversion of an event from one version to another does not potentially break dependent extensions.\n### Converting business events\nIt is not allowed to convert a business type event to an integration type event or to an internal type event.\nBusiness type events define a formal contract that carries an implicit promise not to change in the future. Integration type events do not carry the same promise and can be changed over time. It is then not allowed to convert a business type event to an integration type event.\nAs a business type event defines an event that can be subscribed to by other dependent extensions, it is not allowed to convert it to an internal event. This would break dependent extensions which are subscribing to this event.\n### Converting integration events\nIt is not allowed to convert an integration type event to an internal event.\nIt is allowed to convert an integration type event to a business type event when the following two conditions are met:\n the integration event did not expose any global variables, and\n the integration event does not stop exposing the sender to its subscribers (see appsourcecop-as0021).\nAs an integration type event defines an event that can be subscribed to by other dependent extensions, it is not allowed to convert it to an internal events. This would break dependent extensions which are subscribing to this event.\n### Converting internal events\nInternal events can only be subscribed to from within the same module. It is then allowed to turn them into business or integration type events.\n## Examples of valid event type conversion\n### Example 1 - Converting an integration type event to a business type event\nVersion 1.0 of the extension:\n```al\ncodeunit 50100 MyCodeunit\n{\n    [IntegrationEvent(true, false)]\n    procedure MyEvent()\n    begin\n    end;\n}\n```\nVersion 2.0 of the extension:\n```al\ncodeunit 50100 MyCodeunit\n{\n    [BusinessEvent(true)]\n    procedure MyEvent()\n    begin\n    end;\n}\n```\nIn the newer version of the extension, the sender remains exposed through the business type event. The conversion is valid.\n### Example 2 - Converting an internal event to an integration event\nVersion 1.0 of the extension:\n```al\ncodeunit 50100 MyCodeunit\n{\n    [InternalEvent(true)]\n    procedure MyEvent()\n    begin\n    end;\n}\n```\nVersion 2.0 of the extension:\n```al\ncodeunit 50100 MyCodeunit\n{\n    [IntegrationEvent(true, false)]\n    procedure MyEvent()\n    begin\n    end;\n}\n```\nThe event MyEvent now becomes available for other extensions.\n## Examples of nonvalid event type conversions\n### Example 1 - Conversion of a business type event to an internal type event\nVersion 1.0 of the extension:\n```al\ncodeunit 50100 MyCodeunit\n{\n    [BusinessEvent(false)]\n    procedure MyEvent()\n    begin\n    end;\n}\n```\nVersion 2.0 of the extension:\n```al\ncodeunit 50100 MyCodeunit\n{\n    [InternalEvent(false)]\n    procedure MyEvent()\n    begin\n    end;\n}\n```\nIn 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 `'MyEvent' is inaccessible due to its protection level (AL0161)`.\nFor example, the following extension compiles when depending on version 1.0, but fails to compile with version 2.0:\n```al\ncodeunit 50120 AnotherCodeunit\n{\n    [EventSubscriber(ObjectType::Codeunit, Codeunit::MyCodeunit, 'MyEvent', '', true, true)]\n    local procedure MyProcedure()\n    begin\n        // Subscriber logic\n    end;\n}\n```\n### Example 2 - Conversion of an integration type event that exposed variables to a business type event\nVersion 1.0 of the extension:\n```al\ncodeunit 50100 MyCodeunit\n{\n    [IntegrationEvent(true, true)]\n    procedure MyEvent()\n    begin\n    end;\n\n    var\n        myGlobalVariable: Integer;\n}\n```\nVersion 2.0 of the extension:\n```al\ncodeunit 50100 MyCodeunit\n{\n    [BusinessEvent(true)]\n    procedure MyEvent()\n    begin\n    end;\n\n    var\n        myGlobalVariable: Integer;\n}\n```\nIn 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)`.\nFor example, the following extension compiles when depending on version 1.0, but fails to compile with version 2.0:\n```al\ncodeunit 50120 AnotherCodeunit\n{\n    [EventSubscriber(ObjectType::Codeunit, Codeunit::MyCodeunit, 'MyEvent', '', true, true)]\n    local procedure MyProcedure(myGlobalVariable: Integer)\n    begin\n        // Subscriber logic\n    end;\n}\n```\n### Example 3 - Conversion of an integration type event to a business type event that stops exposing its sender\nVersion 1.0 of the extension:\n```al\ncodeunit 50100 MyCodeunit\n{\n    [IntegrationEvent(true, false)]\n    procedure MyEvent()\n    begin\n    end;\n}\n```\nVersion 2.0 of the extension:\n```al\ncodeunit 50100 MyCodeunit\n{\n    [BusinessEvent(false)]\n    procedure MyEvent()\n    begin\n    end;\n}\n```\nIn 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)`.\nFor example, the following extension compiles when depending on version 1.0, but fails to compile with version 2.0:\n```al\ncodeunit 50120 AnotherCodeunit\n{\n    [EventSubscriber(ObjectType::Codeunit, Codeunit::MyCodeunit, 'MyEvent', '', true, true)]\n    local procedure MyProcedure(sender: Codeunit MyCodeunit)\n    begin\n        // Subscriber logic\n    end;\n}\n```\n## Related information\nAppSourceCop Analyzer<appsourcecop>\nGet Started with AL<../devenv-get-started>\nDeveloping Extensions<../devenv-dev-overview>"}