Using AND or OR in SETFILTER

mrigyamrigya Member Posts: 124
Hi All
Please tell me can we use AND or OR operators in SETFILTER

Like RecVar.SETFILTER(RecVar.PostingDate,'<=%1',startDate) AND
RecVar.SETFILTER(RecVar.DueDate'>=%1',EndDate)
IF FIND('-') then
........

Thanks and Regards
Mrigya

Comments

  • kinekine Member Posts: 12,562
    Cannot be done. Search through the forum to find more how to solve that. You can do only AND between filters for different fields. OR must be done in two loops or e.g. using temporary table...

    Edited: see viewtopic.php?t=13671
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • kapamaroukapamarou Member Posts: 1,152
    RecVar.SETFILTER(RecVar.PostingDate,'<=%1 &>=%2',startDate) AND
    RecVar.SETFILTER(RecVar.DueDate=%1 &>=%2',EndDate)

    You should write:
    RecVar.SETFILTER(RecVar.PostingDate,'<=%1 &>=%2',startDate,EndDate);
    RecVar.SETFILTER(RecVar.DueDate=%1 &>=%2',StartDate,EndDate);
    

    This will give you the combined filters (It is like AND meaning that it applies both filters)

    If you want something like OR you could filter on the first field, MARK the records, then filter on the second field, MARK those also, and then remove the filters and show the MARKEDONLY records.

    When using %1 and %2 you need to pass 2 parameters.
  • kinekine Member Posts: 12,562
    kapamarou wrote:
    RecVar.SETFILTER(RecVar.PostingDate,'<=%1 &>=%2',startDate) AND
    RecVar.SETFILTER(RecVar.DueDate=%1 &>=%2',EndDate)

    You should write:
    RecVar.SETFILTER(RecVar.PostingDate,'<=%1 &>=%2',startDate,EndDate);
    RecVar.SETFILTER(RecVar.DueDate=%1 &>=%2',StartDate,EndDate);
    

    This will give you the combined filters (It is like AND meaning that it applies both filters)

    If you want something like OR you could filter on the first field, MARK the records, then filter on the second field, MARK those also, and then remove the filters and show the MARKEDONLY records.

    When using %1 and %2 you need to pass 2 parameters.

    Before using the MARK, read something about the MARK and MS SQL. You can have perfomance problems with that if used with MS SQL.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.