{"title":"CodeCop Warning AA0207","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/analyzers/codecop-aa0207/","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/codecop-aa0207, 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/codecop-aa0207","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 EventSubscriber method must be local.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"CodeCop Warning AA0207","slug":"codecop-warning-aa0207","at":0,"chars":974},{"level":2,"title":"Description","slug":"description","at":67,"chars":57},{"level":2,"title":"Reason for the rule","slug":"reason-for-the-rule","at":124,"chars":191},{"level":2,"title":"Bad code example","slug":"bad-code-example","at":315,"chars":209},{"level":2,"title":"Good code example","slug":"good-code-example","at":524,"chars":216},{"level":2,"title":"Good and bad practices for fixing the rule","slug":"good-and-bad-practices-for-fixing-the-rule","at":740,"chars":97},{"level":2,"title":"Related information","slug":"related-information","at":837,"chars":137}],"text":"# CodeCop Warning AA0207\nThe EventSubscriber method must be local.\n## Description\nThe EventSubscriber method must be local.\n## Reason for the rule\nThe method which is marked as an event subscriber must be local, because it must not to used for external calls. Not marking the method as local might cause confusion.\n## Bad code example\n```al\n[EventSubscriber(ObjectType::Page, Page::\"Customer Card\", 'OnBeforeValidateEvent', 'Address', true, true)]\nprocedure CheckAddressLine(var Rec : Record Customer)\nbegin\n   ...\nend;\n```\n## Good code example\n```al\n[EventSubscriber(ObjectType::Page, Page::\"Customer Card\", 'OnBeforeValidateEvent', 'Address', true, true)]\nlocal procedure CheckAddressLine(var Rec : Record Customer)\nbegin\n   ...\nend;\n```\n## Good and bad practices for fixing the rule\nMake the method local by adding the keyword local.\n## Related information\nCodeCop Analyzer<codecop>\nGet Started with AL<../devenv-get-started>\nDeveloping Extensions<../devenv-dev-overview>"}