Is my FactBox visible?

In one of my previous posts on “how to link a faxbox in code“, I explain .. uhm .. how you can link a faxbox in code.. (you might have guessed that). Now, one of the things you have to keep in mind (as a programmer) when doing so, is the fact that the code on your “OnAfterGetCurrRecord” of your page is always executed. So if you’re putting code there to update your factbox, it’s also going to (try to) execute it, even when it’s not visible. You don’t want that.

So how do I fix this?

Well, it would be nice to be able to use something like this, isn’t it?


Let’s save you the trouble .. you can’t! At least not out-of-the-box..

So why just not creating that property ourselves on our own factbox?

Is that possible?

Well, with PRS, we try to let people think in an (and I should be careful which words I use .. but I’m still gonna .. blame me for it..) “Object Oriented” way. So if the Factbox is my object, I want to add the “Visibility”-property on it!

This is how I did it (or at least tried to do it).

First of all, I declared a global boolean on the factbox, which I call “PageIsVisible“.

Now, you want to be able to call this boolean from outside, so you create a global function on your factbox “IsVisible“, like:

IsVisible() : Boolean


Last thing, to “set” your boolean, I rely on the fact that, when you set your factbox visible, the code runs through the “OnOpenPage” trigger. I think it’s quite safe to rely on.. , So, all you do is:


PageIsVisible := TRUE;

It’s as simple as that!

Now you can use this function in your form where you use your page where you wanted to show the factbox, like this:


IF NOT CurrPage.VMFMessageFactbox.PAGE.IsVisible THEN EXIT;

With the new debugger, you can easily see if it works .. as you see below, where I set a breakpoint in the IsVisible-function on my factbox. As you can see, the boolean is false, which was correct.. as my factbox was indeed not visible at that time..

There were a few people who reminded me to write this blog .. so hope this answers the question .. and help them with their situation.

If not .. or you’ve got remarkt .. I’m always happy to get comments!

5.00 avg. rating (99% score) - 5 votes

Permanent link to this article:


3 pings

Skip to comment form

  1. Wouldn’t it be good practice to set PageVisible to false onQueryClosePage?
    Just in case they close the factbox in between, you will have the correct state as well.

  2. Good point! Of course 🙂

    • Sebi64 on February 11, 2013 at 9:12 am
    • Reply

    Thank you for your post.
    I was close from the solution, i just missed the use of the OnOpenPage.

      • waldo on February 11, 2013 at 9:13 am

      Glad i was able to assist you … 🙂

    • Rathin on January 21, 2014 at 8:24 am
    • Reply

    Hi Waldo ,

    i have created a page (Sales line – source table) to show as factbox in the sales order

    i am just using recordlink nothing else..

    The problem is at the first time the “action” control showing once i removed and retored the factbox the action button not showing only caption of the page display and expand and collapse arrow showing

    Could you please assist me.

  3. Hi Waldo

    Thank you for that post and workaround.

    I am trying to determine whether a control on a Page is visible or not (so as to only execute code to populate it, if it is visible for performance reasons e.g. looking up data from other tables). I have done this on Classic Client for years but cannot find a way to do the same thing now we are moving to RTC (NAV 2013 R2).

    The controls are listed but none of the properties are “published” any more, I appreciate that you can control Visibility, Editable properties etc at Run Time using variables but you cannot interrogate the properties. Typically I have used this technique in Lists as the field on each row needs to be explicitly populated using the OnAfterGetRecord trigger.

    Any suggestions or workarounds you can offer would be greatly appreciated.

      • waldo on May 14, 2014 at 2:04 pm

      Sorry .. I really don’t think this is possible, as you need access to the visibility-property of a control .. which you don’t have, I’m afraid.

    • geschwint on September 29, 2020 at 2:55 pm
    • Reply

    Hi Waldo

    Have you noticed the latest about FactBoxes? I have used your example above successfully until now when validating against BC17 when it stopped working. The reason is MS attempt to make BC more responsive, and that I like, and as a consequence the above does not work anymore.

    Why is it not working? Well, the main page is loaded and displayed **before** any factbox is loaded, thus OnOpenPage is not triggered until after everything is done on the main page.

    Reference to the “feature”:

    A workaround for me was to create logic to force data to the Factbox initially before it was loaded, then let IsVisible control if updates should be sent to the factbox. IsVisible was not available until all OnAfterGet* triggers on the main page was run.

      • waldo on September 29, 2020 at 11:04 pm

      Thanks for the remark – and the workaround! 🙂

  1. […] Bron : Waldo’s Blog Lees meer… […]

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.