Options

Resetting filters

RoelofRoelof Member Posts: 377
Hi,

I have a problem with resetting filters.
I created functionality to transfer filters from 1 subform to a second subform on a main form. That works fine except if you go to a next record of the main form. It then still has the previous settings of subform 1.
The OnBeforePutRecord trigger is basically the last trigger before its getting to a next record.
But how can I reset filters.
Note: I used settableview, copy and copyfilters. Make that helps understanding the problem.

Thanks,
Roelof de Jong.
Roelof de Jonghttp://www.wye.com

Comments

  • Options
    kinekine Member Posts: 12,562
    Please, specify, what you want to reach... why you are doing this...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    RoelofRoelof Member Posts: 377
    Hi,

    Well I added functionality to the Service Order form in order to have a link between the Service Item Line and the Service Invoice Line. What I did was adding a second subform to the Service order.
    So you have the mainform which is linked to the Serviceheader table. have 2 subforms: Subform1 which is linked to the Service Item Line table and the second subform which is linked to the Service Invoice Line table. I created a 1:N relationship between subform1 and subform2, which wasn't easy. I found some code on MiBuSo which I used and it works really well, except... that I get an error message when I go to a next Service Header record. It seems to be that the previous filtersetting on Subform1 is still active and not reset. It tries, based on that previous filter to find a Service Item Line, which is not there. I need to do a reset before going to a next record (or even when I create a new record, same error).
    I figured out that trigger 'OnBeforePutRecord' would be my best bet, but it doesn't have any impact when I put code there to reset. I have the feeling that it has something to do with the property-settings of Subform1. However I tried every possible property setting but with no result.

    Any help or suggestions are welcome.

    Thanks,
    Roelof de Jong.
    Roelof de Jonghttp://www.wye.com
  • Options
    kinekine Member Posts: 12,562
    I think, that you must do some init of the filters in OnAfterGetCurrRecord of the main form...

    And, are you using some FIND or GET in your code without IF - THEN statement? Yes? It is the place of the error?...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    RoelofRoelof Member Posts: 377
    Hi Kine,

    I wish it was that simple. No, I checked that. And believe me, I double checked every single trigger and to put code to reset filters. Even property settings on the subform itself I double checked but without any result. I just don't have any clue.

    Please help.

    Thanks,
    Roelof.
    Roelof de Jonghttp://www.wye.com
  • Options
    bbcaibbcai Member Posts: 80
    I have 2 suggestions but dunno will it work:

    1.) Clear(Rec) for Subform 2
    2.) Set Form Property (Save Table View) to No (SubForm 2)
  • Options
    RoelofRoelof Member Posts: 377
    Hi bbcai,

    I already tried that, but without result.
    Roelof de Jonghttp://www.wye.com
  • Options
    kinekine Member Posts: 12,562
    Where stop the debugger?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    RoelofRoelof Member Posts: 377
    Good question, Kine.
    I tried that but the debugger didn't stop at all. The error just pops up without any debugger.
    Roelof de Jonghttp://www.wye.com
  • Options
    kinekine Member Posts: 12,562
    In this case it is somehwere in the automatic section of C/SIDE... try to remove all properties with Links between the forms and replace them with some C/AL code under your control...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.