Skip to main content

Notifications

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

  • MCJordan Profile Picture
    MCJordan 45 on at
    RE: Reload Page with New Record

    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;

               }

  • Verified answer
    YUN ZHU Profile Picture
    YUN ZHU 77,245 Super User 2025 Season 1 on at
    RE: Reload Page with New Record

    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
    MCJordan 45 on at
    RE: Reload Page with New Record

    How it works with existing record (Model): 

    pastedimage1666207805899v2.png

    pastedimage1666207816549v3.png

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,160 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,962 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans