«

»

Print this Post

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?

IF NOT CurrPage.MyFactBox.PAGE.VISIBLE THEN …;

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

EXIT(PageIsVisible);

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:

OnOpenPage()

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:

UpdateFactbox()

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 (98% score) - 5 votes

Permanent link to this article: http://www.waldo.be/2013/02/11/is-my-factbox-visible/

7 comments

3 pings

Skip to comment form

  1. Magno

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

    Good point! Of course 🙂

  3. Sebi64

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

    1. waldo

      Glad i was able to assist you … 🙂

  4. Rathin

    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.

  5. Graeme

    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.

    1. waldo

      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.

  1. Is my FactBox visible? | Pardaan.com

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

Leave a Reply

%d bloggers like this: