"Business Central关联字段"
示例代码如下:
1、创建表1 "Sales Order" 和表2 "Customer":
table Sales Order
{
field(Sales Order No.; Code[20])
field(Customer No.; Code[20])
field(Customer Name; Text[50])
field(Current Balance; Decimal[18,2])
field(Document Date; Date)
// 此代码创建名为 "Sales Order No." 的关联字段。
// 此字段将链接到 "Customer No." 字段,并通过 "Customer No." 获取 "Customer Name" 和 "Current Balance" 。
field(Customer; Lookup(Customer No.; Customer Name; Current Balance))
}
table Customer
{
field(Customer No.; Code[20])
field(Customer Name; Text[50])
field(Current Balance; Decimal[18,2])
}
2、在页面上使用 Sales Order 表中的关联字段:
page Sales Order Card
{
// 在页面布局中添加
// 列表卡片顶部的标题
layout
{
group(General)
{
field("Sales Order No."; "Document Date")
field("Customer No."; "Customer")
{
// 设置格式
ApplicationArea = All;
CaptionClass = Customer;
MultiLine = false;
NewLine = false;
ShowCaption = true;
}
field(Current Balance)
field("Customer Name")
{
// 将 "Customer Name" 字段标记为只读
ApplicationArea = All;
Editable = false;
}
}
}
}