Hello, I was hoping someone could help me with this:
I am having issue with a Document page that I've created that works well, however I've added two functions to copy the record to a new Model or to a new Rev. When these actions are selected we want the page to reload with the new Model or Rev. This works fine if you start from the list page and select an existing Model, then select the action, but it does not work the same when you have just created the Model and have not yet left the page. The new Model or Rev is created, but the page does not reload to the new record.
I cannot seem to find the correct code to close the current record and reload the new one. The following code works correctly when starting with an existing record, but not when the record has just been created and you have not left the page. Note: I did confirm that the first new record exists (when Copy Model or Rev action is selected) even though the page has not closed.
action("Copy to New Model")
{
ApplicationArea = All;
Image = CopyDocument;
trigger OnAction();
var
PrcModelFun: Codeunit "Price Model Functions";
NewModNo: Code[20];
NewRev: Decimal;
ModelHdr: Record "Price Model Header";
begin
CurrPage.SaveRecord();
NewModNo := PrcModelFun.CopyModeltoModel(rec."Model No.", rec.Revision);
NewRev := 0;
//reload page with New record
ModelHdr.get(NewModNo, NewRev);
CurrPage.SetRecord(ModelHdr);
NumNote := 0;
UpdateNoteExpression();
CurrPage.Update(False);
end;
}
Zhu,
Thank you! After I added the Page as a variable in the Procedure I was able to reopen the page with the new record.
action("Copy to New Model")
{
ApplicationArea = All;
Image = CopyDocument;
trigger OnAction();
var
PrcModelFun: Codeunit "Price Model Functions";
NewModNo: Code[20];
NewRev: Decimal;
ModelHdr: Record "Price Model Header";
PriceModelCard: Page "Price Model Card";
begin
CurrPage.SaveRecord();
NewModNo := PrcModelFun.CopyModeltoModel(rec."Model No.", rec.Revision);
NewRev := 0;
//reload page with New record
ModelHdr.get(NewModNo, NewRev);
CurrPage.close();
PriceModelCard.SetRecord(ModelHdr);
PriceModelCard.Editable := true;
PriceModelCard.run();
end;
}
Hi, What happens when you close this page and reopen a new one in your code?
A simple example, https://yzhums.com/16756/
Hope this can give you some hints.
Thanks.
ZHU
How it works with existing record (Model):
André Arnaud de Cal...
292,160
Super User 2025 Season 1
Martin Dráb
230,962
Most Valuable Professional
nmaenpaa
101,156