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...
Answered

Closing a page before it is even opened ?

(0) ShareShare
ReportReport
Posted on by 237

Hello,

Is it possible to close a page even it is fully opened with whatever data it is associated with?

I am trying to develop a page that opens normally with some data but would like to skip this page under certain conditions and move on to another page when the first page is no longer necessary.

Please advise.

Thank you.

  • Verified answer
    Marco Mels Profile Picture
    Microsoft Employee on at

    Hello,

    We currently do not have dedicated Dev support via the Dynamics 365 Business Central forums, but I wanted to provide you some additional resources to assist. If you need assistance with debugging or coding I would recommend discussing this on one of our communities.

    www.yammer.com/dynamicsnavdev

    dynamicsuser.net/.../developers

    I will open this up to the community in case they have something to add.

    Thanks.

  • adams1124 Profile Picture
    237 on at

    Thank you, Marco.

    I am already in the Yammer community but thought I should not ask about AL programming in detail.

    I will post a question there when I have something else.

  • Suggested answer
    RockwithNav Profile Picture
    9,229 Super User 2026 Season 2 on at

    I wont recommend this way because even if you achieve this via some workaround you will end up with performance issue.

  • adams1124 Profile Picture
    237 on at

    Thank you for your reply.

    May I ask what kind of performance issue there may be?

  • Suggested answer
    Greg Enns Profile Picture
    1,122 on at

    To avoid performance issue, do your TestSomething before the page opens.

    Sounds like you want...

    If TestSomething THEN

     SometimesPage.RUN; (or RUNMODAL)

    NextPage.RUN;

    If that is not possible, then you could probably put code in OnAfterGetRecord Subscriber which would look like this:

    If TestSomething THEN

    CurrPage.CLOSE;

  • adams1124 Profile Picture
    237 on at

    Thank you, Greg.

    I will test my code as you advised and will let you know the result.

  • adams1124 Profile Picture
    237 on at

    Hi Greg,

    I tested with Page.Close;

    I used code like this

       trigger OnInit()

       var

           MonthCheck: Text[2];

       begin

           MonthCheck := Format(Today, 0, '<Month,2>');

           if MonthCheck = '11' then

               Message('Closing the page');

           CurrPage.Close()

       end;

    1. In OnInit, the message popped up but the page did not close.

    2. In OnOpenPage, it did not work either and the page opened.

    3. But in OnAfterGetRecord, the message popped up number of times of the record, but the page did close.

    4. In OnAfterGetCurrRecord(), the message popped up only once and the page closed.

    So maybe either OnAfterGetRecord or OnAfterGetCurrRecord can be some solution.

    I will further test this options, and thank you for your help.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 665 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 418 Super User 2026 Season 2

#3
Teagen Boll Profile Picture

Teagen Boll 280 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans