【发布时间】:2020-05-19 02:04:07
【问题描述】:
我对使用 AL for Business Central 构建扩展非常陌生。我正在尝试为学校申请设置扩展。我建立的表工作,它们遵循这个数据模型:
School - Course - Lecture
| /
Teacher
在Card 的School 内,我展示了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;
}
}
}
仍然没有运气。
【问题讨论】:
标签: customization dynamics-business-central dynamics-al