OnAfterGetRecord not triggering in List Page NAV2013

chrisdfchrisdf Member Posts: 82
edited 2013-01-07 in NAV Three Tier
Hi,

I have created an action item in a list page and want the action item to be "enabled" or not depending on a data test that is executed in the OnAfterGetRecord trigger of the list page. I have declared a global boolean variable, set the property "IncludeinDataset" for this variable and then used this variable in the Enabled property of the Action item. The variable gets set or not in the OnAfterGetRecord code pf the list page.

This doesn't work correctly all of the time. Additionally, if I scroll up and down the list page with the debugger enabled, it doesn't seem to be triggering the code in the OnAfterGetRecord section when I move between items in the Page list. It seems to work if the list is short but on a longer list it doesn't.

If I stop on an item where my code would set the variable I am using - and then presh "Refresh" - I get the expected results.

I'm fairly new to RTC - am I missing something about how this client works?

Any help greatly appreciated.

Thanks!

Comments

  • afarrafarr Member Posts: 287
    I tried this, and it worked fine (on a standard Cronus NAV 2013).
    Can you show us your code in OnAfterGetRecord, and a screenshot of the button's properties?
    Or just upload your object here.
    Alastair Farrugia
  • chrisdfchrisdf Member Posts: 82
    Hi,

    It's a pretty straightforward modification to the item list - I created a (second) picture icon that illuminates if a jpeg image of the item exists (we don't load the picture into the database):

    OnInit()
    ItemPictureEnable := TRUE;

    OnAfterGetRecord()
    CLEAR(ItemVariant);
    CLEAR(PictureConv);
    ItemPictureEnable := PictureConv.GetPictureFileName(Rec,ItemVariant) <> ''; (a function that returns true if a jpeg image exists)

    In the Enabled property of the picture Action Item (a new one I created) - I set the value to "ItemPictureEnable"

    What I can't understand is that if I set a breakpoint in the debugger in the OnAfterGetRecord() trigger it doesn't break when scrolling the list. Also if I do a Ctrl+Alt+F1 to zoom on the record the ItemPictureEnable variable is FALSE as I scroll up and down the page list (even when it should be TRUE). If I stop on an item which would set the ItemPictureEnable variable TRUE and press "Refresh" then it works. Of course, if I fire up the debugger and launch the page (from scratch) then the debugger breaks where I would expect but then if I scroll up and down the page list, I can't seem to get the debugger to break where I would expect it to. It's as if the trigger code is just not firing.

    Hope this makes sense - perhaps you could post me the example of what you did so I could cross checkit and see ...??

    Thanks for helping.
  • afarrafarr Member Posts: 287
    I modified the Location List (page 15). I added a Page Action called MyNewAction, just after the PageTransferOrder , with the following non-default properties:

    Name: MyNewAction
    Enabled: BtnEnabled
    RunPageMode: Create
    Image: AddAction
    Promoted: Yes
    PromotedCategory: New

    To enable the button when the location code contains an 'A' I just added the following code in OnAfterGetRecord:
    BtnEnabled := (STRPOS(Code,'A') <> 0);

    I didn't try using the debugger, or Ctrl+Alt+F1, but as I scroll up and down, the button does get enabled when (and only when) the location code contains an A.
    Alastair Farrugia
  • chrisdfchrisdf Member Posts: 82
    Hi,

    I also got it working on a "short" list - the problem occurs when you have a longer list (or so it seems to me!)

    Thanks anyway!
  • afarrafarr Member Posts: 287
    I used a codeunit to insert all locations with 3 letters, from AAA to ZZZ (that's 17,576 locations in all), and it still works well.

    In your function GetPictureFileName, I would suggest passing the parameters by reference (i.e. tick the 'VAR' checkbox), and doing a CALCFIELDS on the field that contains the jpg.
    Could you post the code for that function?
    Alastair Farrugia
  • chrisdfchrisdf Member Posts: 82
    Seems that it works if the trigger code is in OnAfterGetCurrRecord and not OnAfterGetRecord section.

    Looks like NAV triggers the OnAfterGetRecord code only when the page is launched.
Sign In or Register to comment.