Check if record is inside a defined filter

mikmik Member Posts: 79
Hi,
I need a fast solution to check if a record fits a defined filter definition.

Example:
Filter "No." = "1000..2000"
Rec."No." = 1010

How can I check if the record would be inside the filter result? #-o

With kind regards
mik

Answers

  • jordi79jordi79 Member Posts: 275
    Rec.SetfilteR("no.", '1000..2000');
    Rec."no." := '1010';
    if rec.find('=') then
    // record found!!!
    else
    // record not found!!!
  • mikmik Member Posts: 79
    Thank You Jordi! \:D/
    I needed this the first time :oops:

    With kind regards
    mik
  • mdPartnerNLmdPartnerNL Member Posts: 802
    After setting a filter and a findset you could do a get too with the same recordset.
  • vaprogvaprog Member Posts: 1,141
    After setting a filter and a findset you could do a get too with the same recordset.
    How does the FINDSET help?
    GET ignores filters.

    jordi79's solution only works if "No." is the entire primary key and a record with the value you want to test actually exists. In any other scenario you need to insert appropriate test data into a (temporary) table in order to only test that filter/value pair.
  • jordi79jordi79 Member Posts: 275
    If you want to perform a filter within a filter that does not belong to a primary key fields, then you should use "filtergroup" functions. Read the documentation about how it works. But in short it allows some sort of filter "isolation". So that you can filter within a filtered record without removing the earlier filter.
  • krikikriki Member, Moderator Posts: 9,112
    SomeTableTEMP.RESET;
    SomeTableTEMP.DELETEALL(FALSE);
    
    CLEAR(SomeTableTEMP);
    SomeTableTEMP."Field X" := '1010';
    SomeTableTEMP.INSERT(FALSE);
    
    SomeTableTEMP.RESET;
    SomeTableTEMP.SETFILTER("Field X", '1000..2000');
    
    IF NOT SomeTableTEMP.ISEMPTY THEN
    // found!!!
    ELSE
    // NOT found!!!
    

    But be careful with it because SQL Server sorts code-fields differently than native DB (1,2,10 in native becomes 1,10,2 in SQL). And temptables use the native DB sorting. From NAV2013 this should be fixed.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.