FieldRef.SETFILTER - bug?

I have some code that sets filter on a number of fields within a Record based on a setup table. RecRef.GETTABLE(JLEntry); IF ViewFilter.FIND('-') THEN REPEAT CLEAR(FieldRef); FieldRef := RecRef.FIELD(ViewFilter."Field No."); FieldRef.SETFILTER(ViewFilter."Filter String"); UNTIL ViewFilter.NEXT = 0; if RecRef.find('-') then repeat ... until = 0; Unfortunately this does not work. The first FieldRef.SETFILTER works fine (looking at RecRef Table Filters), but the next one overwrites the first filter - even though we are getting different Field Nos. Eg. After the first iteration: ViewFilter.“Field No.” = 64 ViewFilter.“Filter String” = USAGE FieldRef.NUMBER = 64 FieldRef.NAME = Entry Type RecordRef.TableFilter = “Entry Type=USAGE” After the second iteration: ViewFilter.“Field No.” = 32 ViewFilter.“Filter String” = 2000…2110 FieldRef.NUMBER = 32 FieldRef.NAME = Work Type Code RecordRef.TableFilter = “Entry Type=2000…2110” Am I doing something wrong? or is this a bug? I have tried it with and without the CLEAR(FieldRef) line and it is the same.

Hi Nikolai, As far as I understand it, you want to apply different filters on a RecRef variable that are stored in a table but only the first filter is correctly applied, right? I wrote the following code (more less the same as yours) that puts three filters on G/L Entry table: 1) on field Document Type (filter string = Payment) 2) on field G/L Account No. (filter string = 700000…799999) 3) on field Amount (filter string = >1000) The three filters that I use are stored as records in the ViewFilter table. In my case, all filters are correctly applied. Here is my code (made in 4.0, more less the same as yours): OnRun() RecRef.GETTABLE(GLEntry); IF ViewFilter.FIND(’-’) THEN REPEAT FldRef := RecRef.FIELD(ViewFilter.“No.”); FldRef.SETFILTER(ViewFilter.“Filter String”); UNTIL ViewFilter.NEXT = 0; ShowForm(RecRef); ShowForm(RecRef : RecordRef) GLEntry.SETVIEW(RecRef.GETVIEW); FORM.RUNMODAL(0,GLEntry); After running this code, the default G/L entry form is shown with the filtered set of records. If I click Ctrl+F7, I see the three applied filters… Hope this helps a bit? :slight_smile:

In debuggin to find problems. Try to use the RESET if you are clearing all filters. Try to use the following command to get the filters currently stored: TempString := table.GETFILTERS; You will be able to use them later if needed. Also to determine if filters are not disappearing. Geovanny