Options

Filter AND (use 2 more fields)

casanovacasanova Member Posts: 194
edited 2014-08-19 in NAV Three Tier
Hi All,
i want to filter data with 2 fields when i do open page
how should i do that?
if FieldA = blank and FieldB = blank then
dont show

Thanks

Comments

  • Options
    ppavukppavuk Member Posts: 334
    trigger OnOpenPage
    Setfilter(fieldA, '<>%1', '');
    Setfilter(fieldB, '<>%1', '');
    

    this will show only records, where A and B populated. Of course, depending on your fileds datatypes you have to set right stuff in " ''); "

    0 for integers and options, '' for code and text, '0d' for date, 0t for time, etc...
  • Options
    vaprogvaprog Member Posts: 1,118
    It's actually an OR that you are looking for, the AND you get for free: all filter conditions must be fulfilled. And since a filter is always inclusive, not exclusive, what you really need is
    FieldA <> '' OR Field B <> ''
    

    NAV does not provide for this. You need a work around.

    Some of your options:
    • a FlowField
    • A field that you calculate OnInsert/OnModify
    • MARK(TRUE)/MARKEDONLY(TRUE)
    • SourceTableTemporary=Yes
    • Some Code in OnFindRecord/OnNextRecord
    • a Query object
    You can find many posts concerning this sort of requirement in this forum.
  • Options
    ppavukppavuk Member Posts: 334
    vaprog wrote:
    It's actually an OR that you are looking for,

    I cant see
    if FieldA = blank and FieldB = blank then hide record
    any or here :) but in any case, I agree that OR will not be doable, for OR probably most viable option is OnFindRecord and OnNextRecord triggers. The warehouse shipments are great example of implementation OnFindRecord and OnNextRecord.
  • Options
    casanovacasanova Member Posts: 194
    ppavuk wrote:
    trigger OnOpenPage
    Setfilter(fieldA, '<>%1', '');
    Setfilter(fieldB, '<>%1', '');
    

    this will show only records, where A and B populated. Of course, depending on your fileds datatypes you have to set right stuff in " ''); "

    0 for integers and options, '' for code and text, '0d' for date, 0t for time, etc...

    if we do this then either Field A blank or Field B blank then will be filtered
    i only want to hide if both fields are blank
  • Options
    dbabasdbabas Member Posts: 33
    Try to run your page, using a code like this:

    repeat
    if (NOT yourRecord.fieldA=' ') and (NOT yourRecord.FieldB=' ') then begin
    yourRecord2 := yourRecord;
    yourRecord2.insert;
    end;
    until yourRecord.next=0;

    RUN(pageID, yourRecord2);

    where yourRecord is a Record variable and yourRecord2 is a temporary Record variable of the same table.
Sign In or Register to comment.