Hi everyone,
I am using standard codeunit 46 SelectionFilterManagement to extract a filter from a group of records:
I created the following custom functions in my page:
GetSelectionFilterForXXX(VAR recXXX : Record XXX) : Text
recRef.GETTABLE(recXXX );
EXIT(GetSelectionFilter(recRef,recXXX .FIELDNO(FieldXXX)));
GetRecordsXXX(VAR codXXX : Code[20]) : Text
lrecXXX.RESET;
lrecXXX.SETRANGE(Code,codXXX );
EXIT(GetSelectionFilterForXXX(lrecXXX));
GetSelectionFilter is a standard function in codeunit 46.
The problem is that the filter is not correct in some cases :
For example:
When lrecXXX is filtered on the records with the following values for FieldXXX:
1000,1010,1040,6020,6120,9140
The filter is supposed to be :
1000|1010|1040|6020|6120|9140
BUT
this is what I get :
1000|1010|1040|6020|6120..9140
Is there something wrong with my code?
Or this is some kind of bug in the codeunit itself? Has someone experienced this before?
Thanks in advance
Answers
Codeunit 46 has it's shortcomings, but chances are, the filter you get is correct. The filter returned is meant to be used with the current set of values in the table. Whenever two or more adjacent values are encountered, a range is returned in the resulting filter string. When you apply the returned filter string to the record immediately, do you get a different set of records as those you called GetSelectionFilterForXXX with?
Some of it's flaws:
I consider the fact, that it only works for tables with a single primary key field, a limitation, not a flaw, but still, you should be aware of this.
Thank you for your answer
In this case, how can I get a correct filter?