Regarding filtering

VineethVineeth Member Posts: 4
Is there any way to filter out records from a table when the value of say field1=field2 . Can i set any filter in the OnOpenform of a form?records with field1=field2 should not be shown.I dont want to read all the records and check this condition. Can any filtering be done?

Setfilter("field1",'<>%1',5) possible
setfilter("field1",'<>%1',"field2") not possible.

Please advise

Comments

  • kinekine Member Posts: 12,562
    No, it is not possible. You have more ways:

    add new field to the table, which will be True if fields are same, and refresh this field each time the fields are changed (OnValidate, OnModify or somewhere else).

    You can add FlowField with definition like:

    Exists record with same primary key where FIELD1 = FIELD2?

    After that, you can filter to this, but "YOU ARE FILTERING ON FLOFIELD" and it means that performance will be not good and can have impact to other processes...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • BeliasBelias Member Posts: 2,998
    setfilter("field1",'<>%1',"field2") not possible.

    this is not working (and I don't know a way to let it work :mrgreen: ) because:
    -if you are not looping in "rec", "field2" has no value
    -if you are loopin in "rec"...well...the code is nonsense :mrgreen:

    BTW, i'm afraid you have to loop the entire table and test, mark...and then show markedonly, also you can use temptables, which is better if you're on SQL...
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • garakgarak Member Posts: 3,263
    you have 3 options:

    first and second you need an new Field in your table.
    1. create an new field (bool) and set it true in all your codes where you modify this table) if field 1 = field 2
    2. create an new field (bool) as Flowfield (exist Table field 1 = field 2) (but filtering of an calculated field is #-o

    3. in you code you can "filter" with an loop
    repeat
    if not (field 1 = field 2) then begin
    her you can store the records or mar or what else
    end;
    until rec.next = 0;

    The reason, why you can't do filter the values (in SQL you can) is, navision must ever know the filtered values to filter. In SQl the Server runs through the recs and checked than (like a loop)
    Do you make it right, it works too!
  • VineethVineeth Member Posts: 4
    thank u guys...i used marking and later on markedonly to filter the records...i wanted to know if filter statement works if we compare 2 fields. it doesn't work isn't it ..thanks
Sign In or Register to comment.