{"title":"Protected variables","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/devenv-protected-variables/","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-protected-variables, 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-protected-variables","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 protected keyword can be used to make variables accessible between tables and table extensions, pages and page extensions and report and report extensions.","date":"2024-05-24","meta":{"topic":"article"},"outline":[{"level":2,"title":"Syntax","slug":"syntax","at":456,"chars":122},{"level":2,"title":"Example","slug":"example","at":578,"chars":1384},{"level":2,"title":"Related information","slug":"related-information","at":1962,"chars":165}],"text":"> APPLIES TO: Business Central 2019 release wave 2 and later\nThe protected keyword can be used to make variables accessible between tables and table extensions, pages and page extensions and reports and report extensions. It also makes variables accessible between extensions if they belong to apps, which depend on each other. If you want to only expose some variables as protected, you must create two sections of var declarations. See the syntax below.\n## Syntax\n```al\nprotected var\n        myInt: Integer; // protected var\n\nvar\n        myLocalInt: Integer; // local var\n```\n## Example\nThe example below illustrates how to declare and use a protected variable.\n```al\npage 50100 MyPage\n{\n    SourceTable = Customer;\n    PageType = Card;\n\n    layout\n    {\n        area(Content)\n        {\n            group(General)\n            {\n                field(Name; Name)\n                {\n                    ApplicationArea = All;\n                }\n            }\n            group(Advanced)\n            {\n                Visible = ShowBalance;\n\n                field(Balance; Balance)\n                {\n                    ApplicationArea = All;\n                }\n            }\n        }\n    }\n\n    protected var\n        ShowBalance: Boolean;\n}\n\npageextension 50101 MyPageExt extends MyPage\n{\n    layout\n    {\n        addlast(Content)\n        {\n            group(MoreBalance)\n            {\n                Visible = ShowBalance; // ShowBalance from MyPage\n\n                field(\"Balance (LCY)\"; \"Balance (LCY)\")\n                {\n                    ApplicationArea = All;\n                }\n            }\n        }\n\n    }\n\n    actions\n    {\n        addlast(Navigation)\n        {\n            action(ToggleBalance)\n            {\n                ApplicationArea = All;\n                trigger OnAction()\n                begin\n                    ShowBalance := not ShowBalance; // Toggle ShowBalance from MyPage.\n                end;\n            }\n        }\n    }\n}\n```\n## Related information\nAL method reference<methods-auto/library>\nproperties/devenv-properties\nproperties/devenv-access-property\nproperties/devenv-extensible-property"}