Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Suggested answer

Page.Close() does not work

Posted on by 184

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();
Categories:
  • Suggested answer
    Muaaz Deyab Profile Picture
    Muaaz Deyab 184 on at
    RE: Page.Close() does not work

    I solved this by using the CodeUnit ItemCostManagment

  • Muaaz Deyab Profile Picture
    Muaaz Deyab 184 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
    YUN ZHU 73,696 Super User 2024 Season 2 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
    Muaaz Deyab 184 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
    ShanAbeywicrema 940 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
    YUN ZHU 73,696 Super User 2024 Season 2 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
    Muaaz Deyab 184 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
    Mohana Yadav 59,139 Super User 2024 Season 2 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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans