Hi, Readers.
In Dynamics 365 Business Central, pages are the main way to display and organize data. A page is defined in code as an object composed of controls, properties, actions, and triggers.
On the field, we can set the Caption Property to set the string in the user interface. This property supports Table Field and Page Field.
Caption Property: Sets the string that is used to identify a control or other object in the user interface.
If you set the Caption Property of Table Field and Page Field at the same time, the caption of Page Field will be displayed on the user interface.
For example,
table 50100 “Lab Book”:
page 50012 “Book List”: SourceTable = “Lab Book”;
In Business Central:
Recently I was asked an interesting question, some standard APIs have the following situation. The page field caption is different from the table field caption. For example, the caption of Document Date is Order Date in page 30028 “APIV2 – Sales Orders”😑:
When getting the order date via the standard API, this order date may be different from the Order date on the order, because it is not the same field.
So the first question, how to export all the fields on the page including caption.
When we discussed how to export all fields in all tables in Dynamics 365 Business Central before, we learned that table 2000000041 “Field” can be used to export all table fields including Field Caption.
We also discussed how to export all fields/controls in all pages in Dynamics 365 Business Central (Page Control Field), but this does not include Page field caption.
There are some system tables with Scope = OnPrem available in the system, but I want to find one that can also be used in the SaaS version.
I finally found table 2000000202 “All Control Fields”.
As you might know, we can add the table=<TableID>
parameter to the client’s address (URL), replacing <TableID>
with the ID of the table that we want to view. But please note that this table cannot be opened by this way.
Your license does not grant you the following permissions on TableData All Control Fields: Read.
We only need to create a list page to see the values inside the table.
Source Code:
page 50010 "ZY All Control Fields"
{
ApplicationArea = All;
Caption = 'ZY All Control Fields';
PageType = List;
SourceTable = "All Control Fields";
UsageCategory = Lists;
layout
{
area(content)
{
repeater(General)
{
field("Object Type"; Rec."Object Type")
{
ToolTip = 'Specifies the value of the Object Type field.';
}
field("Object ID"; Rec."Object ID")
{
ToolTip = 'Specifies the value of the Object ID field.';
}
field("Control ID"; Rec."Control ID")
{
ToolTip = 'Specifies the value of the Control ID field.';
}
field("Control Name"; Rec."Control Name")
{
ToolTip = 'Specifies the value of the Control Name field.';
}
field(Caption; Rec.Caption)
{
ToolTip = 'Specifies the value of the Caption field.';
}
field("Data Type"; Rec."Data Type")
{
ToolTip = 'Specifies the value of the Data Type field.';
}
field("Data Type Length"; Rec."Data Type Length")
{
ToolTip = 'Specifies the value of the Data Type Length field.';
}
field("Option String"; Rec."Option String")
{
ToolTip = 'Specifies the value of the Option String field.';
}
field("Option Caption"; Rec."Option Caption")
{
ToolTip = 'Specifies the value of the Option Caption field.';
}
field("Related Table ID"; Rec."Related Table ID")
{
ToolTip = 'Specifies the value of the Related Table ID field.';
}
field("Related Field ID"; Rec."Related Field ID")
{
ToolTip = 'Specifies the value of the Related Field ID field.';
}
field("Source Expression"; Rec."Source Expression")
{
ToolTip = 'Specifies the value of the Source Expression field.';
}
}
}
}
}
This table not only includes Page, but also Control fields of Report and XMLport
Let me add the filter for the API page (page 30028 “APIV2 – Sales Orders”). We can easily find this record🎊.
We can use Open in Excel feature to export all the data. Of course, you can also directly make a tool to export these data without opening the page.
Second question, is it possible to display Table Field Caption together on this page? This makes it easier to compare.
Yes, it’s not difficult, this table contains Related Table ID and Related Field ID field, so we can combine it with the table 2000000041 “Field” mentioned above.
For example,
Looks good.
Source Code:
page 50010 "ZY All Control Fields"
{
ApplicationArea = All;
Caption = 'ZY All Control Fields';
PageType = List;
SourceTable = "All Control Fields";
UsageCategory = Lists;
layout
{
area(content)
{
repeater(General)
{
field("Object Type"; Rec."Object Type")
{
ToolTip = 'Specifies the value of the Object Type field.';
}
field("Object ID"; Rec."Object ID")
{
ToolTip = 'Specifies the value of the Object ID field.';
}
field("Control ID"; Rec."Control ID")
{
ToolTip = 'Specifies the value of the Control ID field.';
}
field("Control Name"; Rec."Control Name")
{
ToolTip = 'Specifies the value of the Control Name field.';
}
field(Caption; Rec.Caption)
{
Caption = 'Page Field Caption';
ToolTip = 'Specifies the value of the Caption field.';
}
field(FieldCaption; FieldCaption)
{
Caption = 'Table Field Caption';
}
field("Data Type"; Rec."Data Type")
{
ToolTip = 'Specifies the value of the Data Type field.';
}
field("Data Type Length"; Rec."Data Type Length")
{
ToolTip = 'Specifies the value of the Data Type Length field.';
}
field("Option String"; Rec."Option String")
{
ToolTip = 'Specifies the value of the Option String field.';
}
field("Option Caption"; Rec."Option Caption")
{
ToolTip = 'Specifies the value of the Option Caption field.';
}
field("Related Table ID"; Rec."Related Table ID")
{
ToolTip = 'Specifies the value of the Related Table ID field.';
}
field("Related Field ID"; Rec."Related Field ID")
{
ToolTip = 'Specifies the value of the Related Field ID field.';
}
field("Source Expression"; Rec."Source Expression")
{
ToolTip = 'Specifies the value of the Source Expression field.';
}
}
}
}
var
FieldCaption: Text[80];
trigger OnAfterGetRecord()
var
FieldRec: Record Field;
begin
FieldCaption := '';
if FieldRec.Get(Rec."Related Table ID", Rec."Related Field ID") then
FieldCaption := FieldRec."Field Caption";
end;
}
Give it a try!!!😁
END
Hope this will help.
Thanks for reading.
ZHU
コメント