Options

how to do a double filter

haritza10haritza10 Member Posts: 28
edited 2012-09-28 in Navision Attain
Hi everybody, i have a problem and i don't know how to resolve it.

I want to do this :
RECORD.SETFILTER(FIELD1,FIELD2,'=%1|=%2',VALUE1, VALUe2);

This code is impossible to do in Navision but nobody knows how can i do this code in different way.

Thanks a lot. :wink:

Comments

  • Options
    Francis_MalengierFrancis_Malengier Member Posts: 28
    hi,

    in navision you would do it using the option to mark records.

    - mark the necessary records (ctrl-f1)
    - if all records are marked, select view--> marked only

    if you check the help, you will find that these steps can also be performed using funtions (mark(), markedonly())

    Hope this helps
  • Options
    Christian_BuehlChristian_Buehl Member Posts: 145
    Hey, thats crazy what you try to do :oops:
    Do it this way:

    If you want to select a simple range use the setrange command
    rec.setrange(field,fromvalue,tovalue);

    If you want to select some values do it like in the graphic interface
    filterstring := 'value1|value2';
    // Alternative: filterstring := strsubstno('%1|%2',value1,value2);
    rec.setfilter(field, filterstring);

    If you want to filter different fields the use the method above on each field
    rec.reset;
    rec.setfilter(field1,filterstring1);
    rec.setfilter(field2,filterstring2);

    Dont forget to reset all filters with rec.reset before you set the intended filters. Otherwise you can receive unexpected results from filtersettings you have done before.
  • Options
    haritza10haritza10 Member Posts: 28
    I want to do a filter with two fields. I want to filter a record by one field OR another field. This is my problem --> ONE FIELD "OR" ANOTHER FIELD NOT ONE FIELD "AND" ANOTHER FIELD.
  • Options
    Christian_BuehlChristian_Buehl Member Posts: 145
    This issue is a little bit tricky but in Navision its possible doe do with some code:

    You need an independend filter criteria which can be done by marking the records. Another possibility is to work with temporary tables.

    So how to do:
    rec.reset;
    rec.setfilter(field1,filterstring1);
    if rec.find('-') then repeat              
      rec.mark(true);                 // Mark all selected records
    until rec.next = 0;
    rec.setrange(field1);     // clear previous filter
    
    rec.setfilter(field2,filterstring2);    // Now the records with the second criteria
    if rec.find('-') then repeat              
      rec.mark(true);                 // Mark all selected records
    until rec.next = 0;
    rec.setrange(field2);     // clear previous filter
    
    rec.markedonly(true);  // Now select all marked
    // From now on you have only the selected records 
    
  • Options
    haritza10haritza10 Member Posts: 28
    thank you, this is that i want.
    :D


    Thanks a lot Christian.
  • Options
    Francis_MalengierFrancis_Malengier Member Posts: 28
    that's what I ment in my previous post
  • Options
    jigneshdhandhajigneshdhandha Member Posts: 41
    This Code Help in my Developement

    Thank you Very Much Christian....
Sign In or Register to comment.