我对使用 AL for Business Central 构建扩展非常陌生。我正在尝试为学校申请设置扩展。我建立的表工作,他们遵循这个数据模型:
School - Course - Lecture
| /
Teacher
在Card
for 中School
,我展示了 for 的列表部分Course
。它正确显示给定学校的所有课程。到现在为止还挺好。但是现在,每当我从这个视图创建一个Course
时,我必须记住SchoolId
手动设置,但我想自动执行此操作,因为我们已经知道School
我们在哪个视图中。
该Course
表如下所示:
table 50110 Course
{
DataClassification = ToBeClassified;
DrillDownPageId = "Course List";
LookupPageId = "Course List";
fields
{
field(1; "No."; Code[20])
...
field(5; "SchoolId"; Code[20])
{
DataClassification = ToBeClassified;
TableRelation = School."No.";
}
}
keys
{
key(PK; "No.")
{
Clustered = true;
}
}
}
Course
列表部分明确不包含SchoolId
,因为我们希望它会自动管理:
page 50118 "Course List Part"
{
PageType = ListPart;
UsageCategory = None;
SourceTable = Course;
CardPageId = "Course Card";
// InsertAllowed = false;
layout
{
area(Content)
{
repeater(GroupName)
{
field("No."; "No.") { ApplicationArea = All; }
field(Name; Name) { ApplicationArea = All; }
field(CourseOwnerId; CourseOwnerId) { ApplicationArea = All; }
// field(SchoolId; SchoolId) { ApplicationArea = All; }
}
}
}
}
School
卡片在适当的Course list part
视图上调用:
page 50117 "School Card"
{
PageType = Card;
UsageCategory = None;
SourceTable = School;
layout
{
area(Content)
{
group(General)
{
field("No."; "No.")
{
ApplicationArea = All;
}
field(Name; Name)
{
ApplicationArea = All;
}
}
group("Extras 1")
{
part("Courses"; "Course List Part")
{
ApplicationArea = All;
SubPageLink = SchoolId = field("No.");
UpdatePropagation = Both;
}
}
}
}
}
当然,还有School
将No.
属性设置为主键的表:
table 50113 School
{
DataClassification = ToBeClassified;
DrillDownPageId = "School List";
LookupPageId = "School List";
fields
{
field(1; "No."; Code[20])
{
DataClassification = ToBeClassified;
}
...
}
keys
{
key(PK; "No.")
{
Clustered = true;
}
}
}
尽管如此,还是没有运气。