Options

Table Filter question. Any assistance please?

merrilmerril Member Posts: 38
I want to set a filter on the Fixed asset table where the "component of main asset" field is = to blank or is equal to the asset no. Is this possible?

I tried something like this

rFixedAsset.setfilter(rFixedAsset."Component of Main Asset",'%1|%2','',"FA No.");

but this does not work as the field FA No is not found. Is there another method to do this.

Thanks in advance.

Comments

  • Options
    mouliyadavmouliyadav Member Posts: 9
    A..Z
    A range from A to Z

    A | G
    A or G

    F.. & *A/S
    A range from F and A/S is included in the field.

    <>B
    All except B

    <>''
    All not blank

    <=200 | >500
    All less than or equal to 200 or greater than 500


    Using a filter with replacement field:

    This filter selects all accounts in the range from 100 to 200 and No. 300

    "G/L Account".SETFILTER("No.", '%1..%2|%3', '100', '200', '300');

    Using a filter entered directly in a string:

    This filter, which is entered as a string, corresponds to the previous example. It too selects all accounts in the range from 100 to 200 and No. 300.

    "G/L Account".SETFILTER("No.", '100..200|300');



    Documentation Feedback
    from nav help


    http://nav2009.blogspot.com/
  • Options
    merrilmerril Member Posts: 38
    Hi mouliyadav,

    Thanks for the info but those examples will not work for what I am trying to do. I am not trying to filter a field for certain values. I need to filter on field according to the value of another field.

    In sql terms the where clause would be as follows:
    where "Component of Main Asset" = "" or "Component of Main Asset" = "FA No."
    

    An alternative would be to read all the records in the table and then use an IF STATEMENT to determine if the current record meets that criteria. I would however rather not do that as that would mean that each all the records in the table must be read each time, and that to me is poor design
  • Options
    krikikriki Member, Moderator Posts: 9,098
    Your setfilter statement is correct.
    I would do this to check if the filters you put are correct:
    MESSAGE('<%1>',rFixedAsset.GETFILTERS);
    
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • Options
    merrilmerril Member Posts: 38
    kriki wrote:
    Your setfilter statement is correct.
    I would do this to check if the filters you put are correct:
    MESSAGE('<%1>',rFixedAsset.GETFILTERS);
    

    The program will not compile because it says that "FA No." is an unknown variable. I do not want to filter on a variable. I need to filter on another field in the table
  • Options
    MBergerMBerger Member Posts: 413
    merril wrote:
    ...I need to filter on another field in the table
    Unfortunately, that's not possible in NAV using filters. You'll have to do that via code inside the loop.
  • Options
    merrilmerril Member Posts: 38
    MBerger wrote:
    merril wrote:
    ...I need to filter on another field in the table
    Unfortunately, that's not possible in NAV using filters. You'll have to do that via code inside the loop.


    So I am going to have to resort to reading all the records each time and then using an IF STATEMENT to ignore the records that I dont need
  • Options
    MBergerMBerger Member Posts: 413
    merril wrote:
    MBerger wrote:
    merril wrote:
    ...I need to filter on another field in the table
    Unfortunately, that's not possible in NAV using filters. You'll have to do that via code inside the loop.


    So I am going to have to resort to reading all the records each time and then using an IF STATEMENT to ignore the records that I dont need
    That is the general idea, yes.
Sign In or Register to comment.