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;
}