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

Announcements

No record found.

News and Announcements icon
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 39

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();
I have the same question (0)
  • Suggested answer
    Mohana Yadav Profile Picture
    61,206 Super User 2026 Season 1 on at

    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.

  • Muaaz Deyab Profile Picture
    39 on at

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

  • Suggested answer
    YUN ZHU Profile Picture
    99,611 Super User 2026 Season 1 on at

    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

  • Suggested answer
    ShanAbeywicrema Profile Picture
    948 on at

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

    Solution01.jpg

  • Muaaz Deyab Profile Picture
    39 on at

    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
    YUN ZHU Profile Picture
    99,611 Super User 2026 Season 1 on at

    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
    39 on at

    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
    Muaaz Deyab Profile Picture
    39 on at

    I solved this by using the CodeUnit ItemCostManagment

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,065 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,132 Super User 2026 Season 1

#3
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 703 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans