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 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기