-
Notifications
You must be signed in to change notification settings - Fork 33
LC0027
Arthur van de Vondervoort edited this page Dec 27, 2024
·
8 revisions
The idea behind this rule is to raise awareness that there is the option of utilizing the Page Management
codeunit rather than invoking Page.Run(0, ...)
directly.
The benefits:
- Automatically determine the appropriate page to run (Sales Order vs. Sales Quote vs. ...).
- Automatically an extra check for IsGuiAllowed()
- Automatically converts the 'Rec-Related' Variant to a RecordRef
- OnAfterGetPageID event publisher for extensions (and other similar event publishers)
Calling the Page.Run()
function directly
local procedure OpenPage()
var
SalesHeader: Record "Sales Header";
begin
Page.Run(Page::"Sales Quote", SalesHeader);
end;
Calling the Page.Run()
function through the Page Management codeunit
local procedure OpenPage()
var
SalesHeader: Record "Sales Header";
PageManagement: Codeunit "Page Management";
begin
PageManagement.PageRun(SalesHeader);
end;
The Page Management codeunit is intended for Card pages and Worksheet for journals.
You can utilize the Page Management code also for List pages with the following approach
local procedure OpenPage()
var
SalesHeader: Record "Sales Header";
PageManagement: Codeunit "Page Management";
begin
if SalesHeader.Count() = 1 then
PageManagement.PageRun(SalesHeader)
else
Page.Run(PageManagement.GetDefaultLookupPageIDByVar(SalesHeader), SalesHeader);
end;
This rule wil also be raised when one the tables below is passed as a record variable.
Id | Name |
---|---|
36 | Sales Header |
38 | Purchase Header |
79 | Company Information |
80 | Gen. Journal Template |
81 | Gen. Journal Line |
91 | User Setup |
98 | General Ledger Setup |
112 | Sales Invoice Header |
131 | Incoming Documents Setup |
207 | Res. Journal Line |
210 | Job Journal Line |
232 | Gen. Journal Batch |
312 | Purchases & Payables Setup |
454 | Approval Entry |
843 | Cash Flow Setup |
1251 | Text-to-Account Mapping |
1275 | Doc. Exch. Service Setup |
5107 | Sales Header Archive |
5109 | Purchase Header Archive |
5200 | Employee |
5405 | Production Order |
5900 | Service Header |
5965 | Service Contract Header |
7152 | Item Analysis View |
2000000120 | User |
There are some exceptions where calling directly the Page.Run()
make sense.
Page.Run(Page::"Customer Card");
local procedure SelectCustomer()
var
CustomerRec: Record Customer;
begin
if Page.RunModal(Page::"Customer Lookup", CustomerRec) = Action::LookupOK then
DoStuffWithSelectedCustomer(CustomerRec);
end;
local procedure SelectCustomer()
var
CustomerRec: Record Customer;
CustomerCard: Page "Customer Card";
begin
CustomerCard.SetRecord(CustomerRec);
CustomerCard.Run();
end;