Pages definition

To handle the Customer Category records (insert, modify, delete, and select), we need to have a list page and a card page.

By using the tpage snippet, we have defined a card page (PageType = Card) and a list page (PageType = List).

The list page (Customer Category List_PKT) has an action for creating a default Customer Category record (it calls a method defined in an external codeunit because we don't want business logic on pages).

The code for the list page definition is as follows:

page 50100 "Customer Category List_PKT"
{
PageType = List;
SourceTable = "Customer Category_PKT";
UsageCategory = Lists;
ApplicationArea = All;
CardPageId = CustomerCategoryCard_PKT;
Caption = 'Customer Category List';
AdditionalSearchTerms = 'ranking, categorization';

layout
{
area(content)
{
repeater(Group)
{
field(Code; Code)
{
ApplicationArea = All;
}
field(Description; Description)
{
ApplicationArea = All;
}
field(Default; Default)
{
ApplicationArea = All;
}
field(TotalCustomersForCategory; TotalCustomersForCategory)
{
ApplicationArea = All;
ToolTip = 'Total Customers for Category';
}
}
}
}
actions
{
area(processing)
{
action("Create Default Category")
{
Image = CreateForm;
Promoted = true;
PromotedCategory = Process;
PromotedIsBig = true;
ApplicationArea = All;
ToolTip = 'Create default category';
Caption = 'Create default category';

trigger OnAction();
var
CustManagement: Codeunit "Customer Category Mgt_PKT";
begin
CustManagement.CreateDefaultCategory();
end;
}
}
}
}

As a best practice, to improve the search experience and help users to easily find the correct page by using the search feature of Dynamics 365 Business Central, we have also defined the AdditionalSearchTerms property. These terms will be used in addition to the Caption page property to find the page via the search engine.

The CUSTOMER CATEGORY LIST page appears as follows:

The card page (CustomerCategoryCard_PKT) has different groups for displaying data on separate FastTabs. In the OnAfterGetRecord trigger, we calculate the total sales amount for the category, we assign that value to a global decimal field (called TotalSalesAmount), and we display this variable as a page field. The code is as follows:

page 50101 CustomerCategoryCard_PKT
{
PageType = Card;
ApplicationArea = All;
UsageCategory = Documents;
SourceTable = "Customer Category_PKT";
Caption = 'Customer Category Card';

layout
{
area(Content)
{
group(General)
{
Caption = 'General';
field(Code; Code)
{
ApplicationArea = All;
}
field(Description; Description)
{
ApplicationArea = All;
}
field(Default; Default)
{
ApplicationArea = All;
}
field(EnableNewsletter; EnableNewsletter)
{
ApplicationArea = All;
}
field(FreeGiftsAvailable; FreeGiftsAvailable)
{
ApplicationArea = All;
}
}
group(Administration)
{
Caption = 'Administration';
field(Blocked; Blocked)
{
ApplicationArea = All;
}
}
group(Statistics)
{
Caption = 'Statistics';
field(TotalCustomersForCategory; TotalCustomersForCategory)
{
ApplicationArea = All;
Editable = false;
}
field(TotalSalesAmount; TotalSalesAmount)
{
ApplicationArea = All;
Caption = 'Total Sales Order Amount';
Editable = false;
Style = Strong;
}
}
}
}
var
TotalSalesAmount: Decimal;
trigger OnAfterGetRecord()
begin
TotalSalesAmount := Rec.GetSalesAmount();
end;
}

The ...CUSTOMER CATEGORY CARD page looks like this:

We've also created a page for the extension setup (called Packt Extension Setup), defined as follows:

table 50103 "Packt Extension Setup"
{
DataClassification = CustomerContent;
Caption = 'Packt Extension Setup';

fields
{
field(1; "Primary Key"; Code[10])
{
DataClassification = CustomerContent;
}
field(2; "Minimum Accepted Vendor Rate"; Decimal)
{
Caption = 'Minimum Accepted Vendor Rate for Purchases';
DataClassification = CustomerContent;
}
field(3; "Gift Tolerance Qty"; Decimal)
{
Caption = 'Gift Tolerance Quantity for Sales';
DataClassification = CustomerContent;
}
}

keys
{
key(PK; "Primary Key")
{
Clustered = true;
}
}
}

This page looks like this:

This will permit the users to handle the settings for our extension.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.225.149.32