From DataitemTableView to Code

My DataItemTable here is G/L Account: Following is my DataitemTableView: SORTING(No.) ORDER(Ascending) WHERE(No.=FILTER(4501|4502))

This No. filter allows me get the 2 project Nos in my G/L Account. Instead of ahving this defined from the dataitem properties, I now want to define the filters in code. How do I set this filters, and where?

Thanks.

You must put the following code in the OnPreDataItem-trigger:

SETFILTER(“No.”,‘4501|4502’);

Or more versatile:

SETFILTER(“No.”,’%1|%2’,‘4501’,‘4502’);

or if you are sure there is no value between the starting and ending value:

SETRANGE(“No.”,‘4501’,‘4502’);

So there are a lot of possibilities.

Thanks. Its worked!