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...
Suggested answer

Page.Close() does not work

(0) ShareShare
ReportReport
Posted on by 33

I am trying to close the page after using page.run or page.runModal but it does not wotk. This is the code:

                    AvgCostCalcOverview.SetItem(rec);
                    AvgCostCalcOverview.RunModal();
                    AvgCostCalcOverview.Close();
  • Suggested answer
    Muaaz Deyab Profile Picture
    33 on at
    RE: Page.Close() does not work

    I solved this by using the CodeUnit ItemCostManagment

  • Muaaz Deyab Profile Picture
    33 on at
    RE: Page.Close() does not work

    Thanks for your help, Yes, I created the same page, but the source table is not temp but still cannot figure out how to update the cost USD (my new field) I want to run it inside the Event subscriber (OnAfterInsertValueEntry in codeunit 22). I tried to run the new page, but it does not run until the Codeunit finish.  

  • Suggested answer
    YUN ZHU Profile Picture
    79,097 Super User 2025 Season 1 on at
    RE: Page.Close() does not work

    Emmm, I think you should change a solution.
    I simply checked the source code of this page. Its operations are all for temporary tables. Even if you open and close the page, it will not affect the data outside the page.

    pastedimage1677719715604v1.png

    pastedimage1677719799056v2.png

    Hope this helps.

    Thanks.

    ZHU

  • Muaaz Deyab Profile Picture
    33 on at
    RE: Page.Close() does not work

    Thanks for your Answer, I tried it, but it did not work. The case here is I am calculating the average cost in USD and I want it to update every time the Unit cost updates. I think unit cost is calculated when this page ("Average Cost Calc. Overview") opens so I wrote the code in OnAfterGetRecord (same as BC code).

  • Suggested answer
    ShanAbeywicrema Profile Picture
    944 on at
    RE: Page.Close() does not work

    Can you try this way? This is just my thought, But you can think more. This worked for me. 

    Solution01.jpg

  • Suggested answer
    YUN ZHU Profile Picture
    79,097 Super User 2025 Season 1 on at
    RE: Page.Close() does not work

    Hi, I also tested it, unfortunately it doesn't work.

    pastedimage1677632957905v1.png

    pastedimage1677632972379v2.png

    pastedimage1677633004936v1.png

    I also tried adding processing to trigger OnOpenPage(), but it still had no effect.

    pastedimage1677633021269v2.png

    But the reverse is possible, for example, close the page first and then open the current page again.
    https://yzhums.com/16756/

    I feel like this is by design and may not be possible.
    Hopefully other experts can give you better advice.

    Thanks

    ZHU

  • Muaaz Deyab Profile Picture
    33 on at
    RE: Page.Close() does not work

    this is the Cost Average in Item Card I just want to execute the code in the OnOpenPage then close the page

  • Suggested answer
    Mohana Yadav Profile Picture
    60,199 Super User 2025 Season 1 on at
    RE: Page.Close() does not work

    Could you please explain what are you trying to do?

    Generally we code like

    if AvgCostCalcOverview.RunModal() = Action::LookupOK then

    //Somelogic

    You can check different Actions like OK, Cancel etc.

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

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

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,207 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,923 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans