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!

4 comments
3 pings
Skip to comment form ↓
Magno
February 11, 2013 at 8:07 am (UTC 0) Link to this comment
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.
waldo
February 11, 2013 at 8:14 am (UTC 0) Link to this comment
Good point! Of course
Sebi64
February 11, 2013 at 9:12 am (UTC 0) Link to this comment
Thank you for your post.
I was close from the solution, i just missed the use of the OnOpenPage.
waldo
February 11, 2013 at 9:13 am (UTC 0) Link to this comment
Glad i was able to assist you …
Is my FactBox visible? - Waldo's Blog Microsoft Dynamics NAV - Microsoft Dynamics NAV - Microsoft Dynamics Community
February 12, 2013 at 6:46 am (UTC 0) Link to this comment
[...] http://www.waldo.be/2013/02/11/is-my-factbox-visible/ [...]
Is my FactBox visible? - Waldo's Blog Microsoft Dynamics NAV - NAV Technical Blogs - Microsoft Dynamics Community
February 12, 2013 at 7:03 am (UTC 0) Link to this comment
[...] http://www.waldo.be/2013/02/11/is-my-factbox-visible/ [...]
Is my FactBox visible? | Pardaan.com
February 19, 2013 at 7:02 am (UTC 0) Link to this comment
[...] Bron : Waldo’s Blog Lees meer… [...]