to query with two conditions by sefilter

andyliuandyliu Member Posts: 3
Hi,

Could I use the setfilter to filter data like (a=xx or b=oo)?
And it could show both a=xx and b=oo.

If not, which function I could use?

Thanks!

Comments

  • androjdazandrojdaz Member Posts: 20
    andyliu wrote:
    Hi,

    Could I use the setfilter to filter data like (a=xx or b=oo)?
    And it could show both a=xx and b=oo.

    If not, which function I could use?

    Thanks!
    Hello,
    unfortunately you can not do this using SETRANGE or SETFILTER. You need to use MARK and MARKEDONLY functions instead.

    Good luck!
    That's what she said!
  • navnaidunavnaidu Member Posts: 15
    Hi,

    I think we can use the Setview function to filter more then one.


    Ex:- Define the variables like as follows

    cust Record Customer
    FilterTxt1,FilterTxt2 as code variables

    FilterTxt1 :='YELLOW';
    FilterTxt2 :='10000..32124578';

    cust.init;
    cust.SETVIEW('WHERE(Location Code=FILTER('+ FilterTxt1 +'),No.=FILTER(' + FilterTxt1 +'))');



    Regards,
    gbnaidu.
  • kinekine Member Posts: 12,562
    navnaidu wrote:
    Hi,

    I think we can use the Setview function to filter more then one.


    Ex:- Define the variables like as follows

    cust Record Customer
    FilterTxt1,FilterTxt2 as code variables

    FilterTxt1 :='YELLOW';
    FilterTxt2 :='10000..32124578';

    cust.init;
    cust.SETVIEW('WHERE(Location Code=FILTER('+ FilterTxt1 +'),No.=FILTER(' + FilterTxt1 +'))');



    Regards,
    gbnaidu.
    You cannot, this will give you "a=cccc AND b=ddd" filter, not "a=cccc OR b=ddd". You cannot filter to two different fields with OR between them. You need to do two passes, one for each filter, and the result must be buffered or marked (mark could be problematic on big results). Just search the forum, this was already discussed few times... :whistle:
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • matttraxmatttrax Member Posts: 2,309
    Definitely discussed many times. Your options are MARK or inserting into a temp table. It does require two passes of the record set.
  • andyliuandyliu Member Posts: 3
    I see.

    Thanks all.
Sign In or Register to comment.