Hello! I would like to ask you about the following code for a Navigate page:
link. Could you explain the purpose of the OnInit and OnOpenPage triggers and how they are used in Navigate pages?
The solution they have used calls ToDoRec.Get() in the OnOpenPage() trigger. But what happens if the table is initially empty? This call would throw an error.
Why do we even need the ToDoRec variable? What's the logic behind calling .Get() and then .Init()? Since we're fetching it from the database, wouldn't all the fields already be initialized?
How should we handle the case where the table is empty and .Get() throws an error?
Also, why does the following code:
trigger OnOpenPage()
begin
ToDoRec.Init();
Rec := ToDoRec;
CurrPage.Update();
end;
prevent us from editing fields in the UI on the second step of the wizard (it's as if we have set the Editable property to false)?
When we use this:
trigger OnOpenPage()
begin
ToDoRec.Init();
ToDoRec.Insert(true);
Rec := ToDoRec;
CurrPage.Update();
end;
empty records get added to the database (everything except the primary key is blank).
We have the following trigger in the database:
trigger OnInsert()
var
ToDoRec: Record ToDo;
begin
if ToDoRec."No." = '' then
if ToDoRec.FindLast() then
Rec."No." := IncStr(ToDoRec."No.")
else
Rec."No." := 'TD001';
end;
Thanks in advance!
Answers
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!