web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

Reload Page with New Record

(0) ShareShare
ReportReport
Posted on by 45

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

I have the same question (0)
  • MCJordan Profile Picture
    45 on at

    How it works with existing record (Model): 

    pastedimage1666207805899v2.png

    pastedimage1666207816549v3.png

  • Verified answer
    YUN ZHU Profile Picture
    95,331 Super User 2025 Season 2 on at

    Hi, What happens when you close this page and reopen a new one in your code?

    A simple example, https://yzhums.com/16756/

    pastedimage1666228176074v1.png

    Hope this can give you some hints.

    Thanks.

    ZHU

  • MCJordan Profile Picture
    45 on at

    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;

               }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,143

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,694 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,067 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans