Protected variables
APPLIES TO: Business Central 2019 release wave 2 and later
The 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.
Syntax
protected var
myInt: Integer; // protected var
var
myLocalInt: Integer; // local var
Example
The example below illustrates how to declare and use a protected variable.
page 50100 MyPage
{
SourceTable = Customer;
PageType = Card;
layout
{
area(Content)
{
group(General)
{
field(Name; Name)
{
ApplicationArea = All;
}
}
group(Advanced)
{
Visible = ShowBalance;
field(Balance; Balance)
{
ApplicationArea = All;
}
}
}
}
protected var
ShowBalance: Boolean;
}
pageextension 50101 MyPageExt extends MyPage
{
layout
{
addlast(Content)
{
group(MoreBalance)
{
Visible = ShowBalance; // ShowBalance from MyPage
field("Balance (LCY)"; "Balance (LCY)")
{
ApplicationArea = All;
}
}
}
}
actions
{
addlast(Navigation)
{
action(ToggleBalance)
{
ApplicationArea = All;
trigger OnAction()
begin
ShowBalance := not ShowBalance; // Toggle ShowBalance from MyPage.
end;
}
}
}
}
See also
AL method reference
Properties
Access property
Extensible property
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈