Options

Function to filter from various fields

stonystony Member Posts: 122
edited 2015-02-02 in NAV Three Tier
Hello,

I would like to build a function which have the parameters filter-field and filter-value.
The need for a page.
This Page has given the SourceTableTemporary property = Yes. The data is parsed when the page is started.
Well I thought I can do it with FieldRef. Unfortunately, I have not worked so far.
I have built the following function AddFilter.
CurrentFieldFilter := FilterField.GETFILTER;
IF STRLEN(CurrentFieldFilter > 0 THEN
  CurrentFieldFilter+= '|';
CurrentFieldFilter+= AddFilterText;
FilterFeld.SETFILTER(CurrentFieldFilter);

MESSAGE('Field-Name: %1 und Filter-Value: %2',FilterField.NAME,CurrentFieldFilter);
MESSAGE('FieldrefFilter : %1',FilterField.GETFILTER);

MESSAGE('%1',GETFILTER(Bodentypgruppe));

CurrPage.UPDATE(FALSE);

and call this function so. However here 'SB' the filter value and should be filtered by the field "Bodentypgruppe".
ABCRecRef.OPEN(DATABASE::"Prod.Planungszeilen");
MyFieldRef := ABCRecRef.FIELD(FIELDNO(Bodentypgruppe));

FilterAdd('SB',MyFieldRef);

The first two message commands provide me with the correct results and the third I get the message that no filter is set to this field.

What´s wrong? Or is this not possible.

thanks
stony

Comments

  • Options
    vaprogvaprog Member Posts: 1,118
    Hi stony

    You are setting the filter on a field of an anonymous record accessible through the RecordRef named ABCRecRef.

    Your checking the filter on a field of some default record, probably Rec.

    I could not quite make out where your code is located, but most likely, you will need to use
    ABCRecRef.GETRECORD(Rec);
    
    instead of your OPEN command.
Sign In or Register to comment.