SETFILTER is similar to, but much more flexible than, the SETRANGE procedure because it supports the application of any of the supported Business Central filter procedures to table fields. The SETFILTER syntax is as follows:
Record.SETFILTER(FieldName, FilterExpression [Value],...);
The FilterExpression consists of a string (text or code) in standard Business Central filter format, including any of the operators (<, >, *, &, |, and =) in any legal combination. Replacement fields (%1, %2, ..., %9) are used to represent the values that will be inserted into FilterExpression by the compiler to create an operating filter that's formatted as though it were entered from the keyboard. Just like SETRANGE, prior to applying its filter, the SETFILTER procedure clears any filters that were previously set for the defined field, as in the following example:
- Filter to get only items with No. from 1300 through 1400:
Item.SETFILTER("No."...