Options

SETFILTER returning unwanted results

Hello,
I am receiving unwanted results when filtering on the 'Gen. Journal Batch' table (232) in Nav 2013
The code will produce a list of all of the journal batches being used by the user but I can't figure out how to filter it correctly.
Currently I have the code below which should return 2 rows, 1 row for 'DEFAULT' and 'GENERAL' and another for 'CINDY' and 'CASH RECEI'.
But unfortunately it is returning 3 because 'CASH RECEI' also has a journal with the name 'DEFAULT'.
I understand why the results are returning the way they are but I am stumped on how to fix it without renaming journals.



//Current code to filter
GenJnlBatch.SETFILTER(Name,'DEFAULT|CINDY');
GenJnlBatch.SETFILTER("Journal Template Name",'GENERAL|CASH RECEI');
GenJnlBatch.FILTERGROUP(0);

Thank you for the help,
Jake

Comments

  • Options
    archer89archer89 Member Posts: 337
    check if there are additional fields you can use to filter your list, e.g. recurring, template type, ...
    best regards
    Franz Kalchmair, MVP
    Alias: Jonathan Archer

    please like / agree / verify my answer, if it was helpful for you. thx.
    Blog: http://moxie4nav.wordpress.com/
  • Options
    Big_DBig_D Member Posts: 203
    Yes that is correct Jake, you'll receive 3 lines as 'CASH RECEI' and journal 'DEFAULT' is within your two required filter sets?
    Big D signing off!
  • Options
    oetijr02oetijr02 Member Posts: 4
    edited 2016-08-09
    @Big_D yes it is, I was looking for an alternative solution to get the 2 rows I was looking for. @archer89 provided a solution that should work. Thanks for the help
  • Options
    Big_DBig_D Member Posts: 203
    Hi Oetijr01

    Oh I understand now - thought you was querying a bug in the Setfilters.

    Marking required records is a good tool too for picking and choosing select records also, i.e., for selecting Customer Sales

    CustSales.SETFILTER(Open,'Yes');
    CustSales.SETRANGE("Document Type","Document Type"::Invoice);
    IF CustSales.FIND('-') THEN REPEAT
    IF CustRec.GET(CustSales."Customer No.") THEN
    CustRec.MARK(True);
    UNTIL CustSales.NEXT=0;

    To find marked records:

    CustRec.MARKEDONLY(True);
    IF CustRec.FIND('-') THEN REPEAT
    CustRec.MARK(False);
    UNTIL CustRec.NEXT=0;


    Hope helps
    Big D signing off!
Sign In or Register to comment.