{"title":"AL code actions","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/devenv-code-actions/","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-code-actions, 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-code-actions","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":"Learn about AL code actions in Visual Studio Code, including scope levels, available actions, and how to enable them for your project.","date":"2026-10-16","meta":{"topic":"conceptual"},"outline":[{"level":1,"title":"AL code actions","slug":"al-code-actions","at":0,"chars":8495},{"level":2,"title":"Choose a code action scope","slug":"choose-a-code-action-scope","at":507,"chars":793},{"level":2,"title":"Available code actions","slug":"available-code-actions","at":1300,"chars":5132},{"level":3,"title":"Convert multiple if statements to case","slug":"convert-multiple-if-statements-to-case","at":1461,"chars":323},{"level":3,"title":"Spell check","slug":"spell-check","at":1784,"chars":208},{"level":3,"title":"Interface implementer","slug":"interface-implementer","at":1992,"chars":232},{"level":3,"title":"Make method local","slug":"make-method-local","at":2224,"chars":168},{"level":3,"title":"Use parenthesis for method call","slug":"use-parenthesis-for-method-call","at":2392,"chars":196},{"level":3,"title":"Fix explicit with statements","slug":"fix-explicit-with-statements","at":2588,"chars":248},{"level":3,"title":"Fix implicit with statements","slug":"fix-implicit-with-statements","at":2836,"chars":263},{"level":3,"title":"Fix old report layout","slug":"fix-old-report-layout","at":3099,"chars":274},{"level":3,"title":"Fix for AW0013","slug":"fix-for-aw0013","at":3373,"chars":164},{"level":3,"title":"Convert promoted actions to actionref syntax","slug":"convert-promoted-actions-to-actionref-syntax","at":3537,"chars":286},{"level":3,"title":"Set ApplicationArea default value","slug":"set-applicationarea-default-value","at":3823,"chars":307},{"level":3,"title":"Convert event subscriber parameters","slug":"convert-event-subscriber-parameters","at":4130,"chars":251},{"level":3,"title":"Insert using statement","slug":"insert-using-statement","at":4381,"chars":343},{"level":3,"title":"Convert page control tooltips","slug":"convert-page-control-tooltips","at":4724,"chars":925},{"level":3,"title":"Fix self-reference to use the this keyword","slug":"fix-self-reference-to-use-the-this-keyword","at":5649,"chars":335},{"level":3,"title":"Add namespace","slug":"add-namespace","at":5984,"chars":279},{"level":3,"title":"Sort using statements","slug":"sort-using-statements","at":6263,"chars":169},{"level":2,"title":"Examples of code actions","slug":"examples-of-code-actions","at":6432,"chars":362},{"level":2,"title":"Code actions for promoted actions","slug":"code-actions-for-promoted-actions","at":6794,"chars":818},{"level":2,"title":"Enable AL code actions","slug":"enable-al-code-actions","at":7612,"chars":729},{"level":2,"title":"Related information","slug":"related-information","at":8341,"chars":154}],"text":"# AL code actions\nUse code actions in the AL Language extension for Microsoft Dynamics 365 Business Central to fix code issues and refactor AL code. In Visual Studio Code, a light bulb appears when an action is available. Select the light bulb or press Ctrl+. to see the available actions. Some actions fix errors or warnings. Others are refactorings available at the current cursor position and don't require a diagnostic. Depending on the action, you can apply it to a single instance or a broader scope.\n## Choose a code action scope\nMany code actions let you choose the scope of the fix. The following table explains each scope level.\nScope|Description\nInstance|Applies the action at the current location. Depending on the action, this scope can affect an expression, object, or file.\nDocument|Selects applicable occurrences in the current file. A file can contain multiple AL objects. Some actions also update related files.\nProject|Applies the fix to all applicable occurrences across all files in the current AL project.\nWorkspace|Applies the fix to all applicable occurrences across all projects in the current Visual Studio Code workspace. This scope is relevant in multi-root workspaces.\nWhen multiple scopes are available, choose the light bulb menu entry for the scope you want to apply.\n## Available code actions\nIn AL Language extension for Microsoft Dynamics 365 Business Central, the following code actions are available in the current version.\n### Convert multiple if statements to case\nConverts a chain of `if ... else if` statements into a case statement when the same expression is tested in each condition. This action is available when the cursor or selection is within a suitable chain of equality comparisons against the same expression.\nScope: Instance only.\n### Spell check\nSuggests corrections for misspelled identifiers and keywords. This action is available for certain compiler diagnostics when a similar completion candidate is available.\nScope: Instance only.\n### Interface implementer\nGenerates missing interface procedure implementations in a codeunit. Depending on the diagnostic, you can implement required methods, all missing methods, or a RequiredPending method.\nScope: Instance only.\n### Make method local\nChanges a nonlocal event subscriber procedure to local. This action fixes CodeCop warning AA0207<analyzers/codecop-aa0207>.\nScope: Instance only.\n### Use parenthesis for method call\nAdds missing parentheses to method calls that omit them. Ensures consistent syntax for procedure invocations.\nScope: Instance, document, project, or workspace.\n### Fix explicit with statements\nRemoves explicit with statements and qualifies all member references with the record variable name. This action helps you move away from the deprecated with syntax.\nScope: Instance, document, project, or workspace.\n### Fix implicit with statements\nResolves implicit with usage by adding explicit record variable prefixes to fields accessed without qualification. This action helps you move away from the deprecated with syntax.\nScope: Instance, document, project, or workspace.\n### Fix old report layout\nReplaces the legacy RDLCLayout and WordLayout properties with a rendering layout section. This action is available on reports and report extensions that use legacy layout properties and don't already have a rendering section.\nScope: Instance only.\n### Fix for AW0013\nApplies fixes for analyzer warning analyzers/uicop-aw0013, which flags hidden action groups that contain promoted actions.\nScope: Instance only.\n### Convert promoted actions to actionref syntax\nConverts pages or page extensions from legacy promoted action syntax to the actionref syntax introduced with Business Central 2022 release wave 2. See #code-actions-for-promoted-actions.\nScope: Instance, document, project, or workspace.\n### Set ApplicationArea default value\nSets the ApplicationArea property at the page or report level and removes redundant per-field ApplicationArea declarations. This consolidates the property to the object level.\nScope: Instance, document, project, or workspace. Instance scope applies to a single object.\n### Convert event subscriber parameters\nConverts EventSubscriber attribute arguments from string literals to identifiers. This conversion makes it easy to opt in to the new syntax in a controlled way.\nScope: Instance, document, project, or workspace.\n### Insert using statement\nAdds a using directive for a missing namespace import when the compiler detects an unresolved type in a known namespace. This action is available in files that already declare a namespace.\nScope: Instance. Document, project, and workspace scopes are available when the unresolved name has a single candidate symbol.\n### Convert page control tooltips\nMoves tooltips from page controls down to the underlying table fields. Defining tooltips at the table field level makes them reusable across all pages that display the same field, so you don't have to maintain duplicate tooltip text on each page.\nThe action applies to eligible page fields bound to Rec whose underlying table field is defined in the same project.\nThe action uses the following logic:\n If the table field doesn't have a tooltip yet, the tooltip is moved from the page control to the table field, and the page control tooltip is removed.\n If the table field already has the same tooltip as the page control, the redundant page control tooltip is removed.\n If the table field already has a different tooltip, the action leaves the page control tooltip unchanged. Review these differences manually.\nSee properties/devenv-tooltip-property.\nScope: Instance, document, or project.\n### Fix self-reference to use the this keyword\nAdds the this qualifier to unqualified references to global variables and instance methods. This action fixes CodeCop warning AA0248<analyzers/codecop-aa0248>. See Use the this keyword for codeunit self-reference<devenv-al-this-keyword>.\nScope: Instance, document, project, or workspace.\n### Add namespace\nAdds a namespace declaration to a file based on your project's namespace template, the namespace used in sibling files, or the publisher/project name. See Adopting namespaces in AL<devenv-namespaces-structure>.\nScope: Instance, document, project, or workspace.\n### Sort using statements\nReorders using directives alphabetically within a file, project, or workspace for consistent ordering.\nScope: Document, project, or workspace.\n## Examples of code actions\nThe spell check action can correct a misspelled keyword:\n![Screenshot of the spell check action changing the misspelled AL keyword them to then.]\nThe make method local action is triggered to fix CodeCop warning AA0207<analyzers/codecop-aa0207>:\n![Screenshot of the Make method local action for a nonlocal event subscriber procedure.]\n## Code actions for promoted actions\nUse the code action to convert legacy syntax for promoted actions to the actionref syntax, which is introduced with Business Central 2022 release wave 2. In-client customizations, user personalization, and profile configurations are automatically converted into the new syntax, so this is primarily applicable to DEV extensions. The code action can apply to a single instance, the document, the project, or the workspace.\n![Options for applying code action on actionref syntax]\n> NOTE\n> For Designer extensions, press F6 in Visual Studio Code to publish and open Designer. Open the page that uses the legacy syntax. Select the lock icon, and then select Unlock page to convert the legacy action syntax. Return to Visual Studio Code and press Alt+F6 to download the updated source.\n## Enable AL code actions\nAL code actions are enabled by default. If they're disabled, use either of the following methods to enable them.\nTo edit the setting directly:\n1. Press Ctrl+Shift+P to open the Command Palette, and select Preferences: Open User Settings (JSON).\n2. Set `\"al.enableCodeActions\": true`.\n3. Save the settings file.\nTo use the settings editor:\n1. Press Ctrl+, to open Settings. Choose user or workspace settings depending on where you want to enable the setting.\n2. Go to Extensions > AL Language extension configuration.\n3. Select the Enable Code Actions checkbox.\nActions that fix CodeCop or UICop diagnostics require the corresponding analyzer to be configured and background code analysis to be enabled.\n## Related information\nAL development environment<devenv-reference-overview>\ndevenv-al-outline-view\ndevenv-al-formatter\ndirectives/devenv-directives-in-al"}