How to use SETFILTER with OR logical operation

I want to use filter on two fields of the same table with one value.

There are two columns named as posting date and document date and let's suppose I want to get rows having either posting date =TODAY OR document date =Today.

When I use SETFILTER two times it gives me rows having posting date and document date=TODAY.

BUT I want to get all rows whose posting date is TODAY may be document date is different and all rows whose Document date is TODAY may be posting date has different value.

I hope its enough to understand the scenario.

May be there is no possibilities to use OR with SETFILTER but if you Know another way to solve it then feel free to share with me I'll really appreciate that.

Thank you.

  • You can do this in code using marks, however it is not straight-forward and quite performance hungry.

    with YourRecord do begin
      setrange("Document Date", TODAY);
      if findset then begin
        repeat
          mark(true);
        until next = 0
      end;
      setrange("Document Date");
      setrange("Posting Date", TODAY);
      if findset then begin
        repeat
          mark(true);
        until next = 0
      end;
      setrange("Posting Date");
      markedonly(true);
    end;

    This will get you the desired filter, but as a side effect every record that matches the filter will be read once from the database. This is okay if you want to display them anyway.

  • You should look into using FILTERGROUP(-1), which activates OR-filtering.

    FILTERGROUP(-1);

    SETRANGE(“Docement Date”,TODAY);

    SETRANGE(“posting Date”,TODAY);

    FILTERGROUP(0);

    // Alexander

Related
Recommended