Customizing a factbox with RECORDID

ZoweeZowee Member Posts: 2
edited 2011-09-01 in NAV Three Tier
Hello,

Does anyone have any idea how to link a factbox via the RecordID?

The factbox that will be linked, has a field called "Record ID" of the type Text.
For Example, I want to have a factbox on the Customer List. And this factbox can only contain the records where the RecordID-field is the same as the RecordID of the Customer.

Thanks!

Comments

  • matttraxmatttrax Member Posts: 2,309
    The FactBoxes are controls accessible from the code. You could write a function in the FactBox page to accept a record id and filter based on it. You could call that function every time you get a record from the database (OnAfterGetRecord).
  • BeliasBelias Member Posts: 2,998
    @mattrax: you're perfectly right, but i've noticed a strange behaviour when you do something like that on lists.
    try to create a list based on customers, and a factbox based on customers, too.
    Example:

    Customer list - onaftergetrecord
    Customer.GET("no.");
    currpage.myfactbox.form.setsourcetable(Customer);
    currpage.myfactbox.form.update(false);
    

    Customer Factbox - setsourcetable(VAR Customer: Table 18)
    get(Customer."no.");
    

    Althought this modification is pointless, in my opinion it should work without problems, but it behaves strange (difficult to explain, try it :) ).
    It acts even stranger if you set the list to be a worksheet :shock:
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • matttraxmatttrax Member Posts: 2,309
    edited 2011-06-16
    I finally had a project where I needed this, and yes, it does not work well. For whatever reason, the OnAfterGetRecord trigger does not fire as you move through the list on a Page object.

    My case is a little different. The fact box is unbound, so it has no Source Table. And therefore no SourceTableLink from the main Page.

    I need a way to tell that Fact Box / Sub Page what it needs to display, but with no events firing as I move through the record list, I'm not sure it's possible with NAV code. I've tried OnAfterGetRecord, OnFindRecord, OnNextRecord...I can't figure out any trigger that will fire as you move from one record to the next.

    Surely there is a solution here...

    [Edit] Essentially it only fires for the first line in the list whenever the list is loaded. So OnOpenPage, or when you filter to a new set of values
  • BeliasBelias Member Posts: 2,998
    yes, you got the point matt. The only thing i can say is that i've made a similar page with similar behaviour before (here's the link, 2nd page the last but one post)
    http://www.mibuso.com/forum/viewtopic.php?f=5&t=20084
    and it worked fine in nav2009sp1.

    Now, it seems like the onafter is fired over and over when you open (and probably close, i don't remember) the page, but not when you brows the list(!!onaftergetrecord of card pages work fine, if i remember well).
    i thought to report this to MS, but honestly, it's hard to explain because of my basic english skills :|
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • matttraxmatttrax Member Posts: 2,309
    Those are good solutions, but they work because there is an explicit action calling the form or page. An OnPush trigger for example. Here there is no event to tell the other page to reload itself. :(
  • BeliasBelias Member Posts: 2,998
    yes, it's a shame because it worked, before.
    P.S.: don't lose your time with currpage.UPDATE, altought i think you've already tried :mrgreen:
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • matttraxmatttrax Member Posts: 2,309
    I even tried creating an add-in for the list page that would raise an event when it lost focus, only to find out that add-ins don't work on list pages. This might be one of the most frustrating things I've encountered. I sort of understand it...it's good not to send a request to the database every time you move from one record to another, but there has to be a way on the page object to fire an event like this.
  • BeliasBelias Member Posts: 2,998
    i totally agree with your frustration and to
    it's good not to send a request to the database every time you move from one record to another, but there has to be a way on the page object to fire an event like this.
    this is the same thing i thought: lists are lighter but indeed limited :roll:
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • jreynoldsjreynolds Member Posts: 175
    This is a big frustration with me as well. However, I have discovered a couple of things that may help.
      1. The OnAfterGetRecord trigger is fired as the user moves through the rows of a repeater for a
    Worksheet type page. However, it does not seem to fire for other page types. Perhaps you can use a worksheet instead of a list.

    2. If you link the FactBox to the main page (via the SubformLink property) then the OnFindRecord trigger on the FactBox will fire as the user moves through the rows of the repeater on the main page. You may be able to program the OnFindRecord trigger to do what you need; information about the current record on the main page can be determined by the filters set in filter group 4 on the FactBox.
  • BeliasBelias Member Posts: 2,998
    jreynolds wrote:
    1. The OnAfterGetRecord trigger is fired as the user moves through the rows of a repeater for a Worksheet type page. However, it does not seem to fire for other page types. Perhaps you can use a worksheet instead of a list.
    this doesn't work, if i remember well (or maybe we just didn't want the page to be a wsheet)
    jreynolds wrote:
    2. If you link the FactBox to the main page (via the SubformLink property) then the OnFindRecord trigger on the FactBox will fire as the user moves through the rows of the repeater on the main page. You may be able to program the OnFindRecord trigger to do what you need; information about the current record on the main page can be determined by the filters set in filter group 4 on the FactBox.
    never tried this, thanks for the hint, i'll try it the next time
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • matttraxmatttrax Member Posts: 2,309
    jreynolds wrote:
    2. If you link the FactBox to the main page (via the SubformLink property) then the OnFindRecord trigger on the FactBox will fire as the user moves through the rows of the repeater on the main page. You may be able to program the OnFindRecord trigger to do what you need; information about the current record on the main page can be determined by the filters set in filter group 4 on the FactBox.

    It will fire even if it is not linked. Even if it was linked, though, at that point you would already know the source data and you wouldn't have a generic FactBox anymore.
  • matttraxmatttrax Member Posts: 2,309
    I think I have actually figured out a way to do this. I have gotten it to work with a very basic example, so now it's off to a much larger test set. I will update if everything works out.
  • matttraxmatttrax Member Posts: 2,309
    If anyone is still curious, check out the download here: http://mibuso.com/dlinfo.asp?FileID=1380

    It uses a generic fact box to do most of the work. You should be able to get the idea of how it works from the code and documentation.
Sign In or Register to comment.