{"title":"Reference the current AL object with the \"this\" keyword","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/devenv-al-this-keyword/","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/devenv-al-this-keyword, 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/devenv-al-this-keyword","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":"Use the AL this keyword to qualify object members, improve code readability, and pass the current codeunit instance to other methods.","date":"2026-10-07","meta":{"topic":"concept-article"},"outline":[{"level":1,"title":"Reference the current AL object with the \"this\" keyword","slug":"reference-the-current-al-object-with-the-this-keyword","at":0,"chars":1498},{"level":2,"title":"Scenarios for using this","slug":"scenarios-for-using-this","at":437,"chars":954},{"level":2,"title":"Related information","slug":"related-information","at":1391,"chars":107}],"text":"# Reference the current AL object with the \"this\" keyword\n> APPLIES TO: Business Central 2024 release wave 2 and later.\nThe this keyword is familiar from languages such as C#, JavaScript, and Python. In AL, it provides a self-reference for an object. For codeunits, you can also pass this as an argument or return it as the current codeunit instance. The keyword improves readability by distinguishing object members from local symbols.\n## Scenarios for using this\nThe main benefits of using the this keyword are:\n It allows codeunits to pass a reference to the current object (this) as an argument to another method.\n It improves readability by indicating that a referenced symbol is a member of the object itself.\nThe CodeCop rule analyzers/codecop-aa0248 is enabled by default with a severity level of hidden. Hidden means that it appears as three dots in the editor, but doesn't show up as a diagnostic in the Problems view in Visual Studio Code or in any pipelines. The CodeCop rule identifies places where you can use the this keyword. A code action can update existing code to use the keyword. Learn more about applying code actions in AL code actions<devenv-code-actions>.\n> NOTE\n> The current https://learn.microsoft.com/dynamics365/business-central/application/system-application/module/system-application uses the this keyword to reference methods and globals in the same object.\n## Related information\nCodeCop hidden AA0248<analyzers/codecop-aa0248>\nAL code actions<devenv-code-actions>"}