Filter 2 fields

Kapoue
Kapoue Member Posts: 37
Hello,

I must filter a table with this filter:
Transact_line.SETFILTER("Periodic Disc. Type", '<> ''Mix&Match''' OR Transact_line."Periodic Disc. Group" <> 1);

But my 2 types are differents "Periodic Disc. Type" is an option type and "Periodic Disc. Group" is an Integer.

How can I do?

Thanks in advance

Ben

Comments

  • lubost
    lubost Member Posts: 633
    You can't use the SETFILTER shape this way. It isn't possible combine two fields in one SETFILTER function.

    Try to use one of your filter (most sensitive) and filter fetched records by REPEAT ... UNTIL loop with IF command.
  • Kapoue
    Kapoue Member Posts: 37
    It isn't very optimized and not very practical
  • lubost
    lubost Member Posts: 633
    You can create new field in Transact_line table and in OnInsert or OnModify trigger set value combined from desired fields and then you can filter your requirement together in one step.
  • gulamdastagir
    gulamdastagir Member Posts: 411
    OnAfterGet Record Trigger:
    if (("Periodic Disc. Type"="Periodic Disc. Type"::Mix&Match)OR
    (Transact_line."Periodic Disc. Group"=1)) then

    Message('%1','C/Al is a Piece Of Cake'); =P~
    Regards,

    GD
  • Albertvh
    Albertvh Member Posts: 516
    Use 2 SETFILTER commands

    Transact_line.SETFILTER("Periodic Disc. Type",'<>%1', Transact_line."Periodic Disc. Type"::"Mix&Match");
    Transact_line.SETFILTER("Periodic Disc. Group",'<>1');
    

    Of course it helps if there is a SETCURRENTKEY before the filters

    Hope this helps
  • lubost
    lubost Member Posts: 633
    Albertvh, your code produces AND.
  • Albertvh
    Albertvh Member Posts: 516
    Oops read it too quickly :oops:

    Then maybe the suggestion of using C/AL is the way.


    Albert
  • Kapoue
    Kapoue Member Posts: 37
    The trigger is ok but I'll use this only for a report.

    And if I add this trigger all my codes'll be a little slower, if I add a field with combined values the db will be a little bigger.

    So I prefer have only one report a little slower and do all this in my C/AL code.

    Thank tou