"Gen. Journal Batch".SETFILTER("Template Type",'%1|%2|%3', "Gen. Journal Batch"."Template Type"::Sales, "Gen. Journal Batch"."Template Type"::Purchases, "Gen. Journal Batch"."Template Type"::Payments);In this statement, the filter expression expects the option captions. So there is no way to write rugged and readable code without the value parameters. Also, do not use STRSUBSTNO to insert values into the filter string. STRSUBSTNO does not know about quoting your values for the filter expression, SETFILTER does.
Answers
Setting up in filter can be as follow in c/al:
GenJnlBatch.SetFilter(GenJnlBatch."Template Type",'0;1;2;3;4');
The number is the index of the variable in the optionstring. 0 means General, 1 means Sales and so on...
Or you make an temporary table TmpGen with these options included. GenJnlBatch.SetFilter(GenJnlBatch."Template Type",TmpGenJnlBatch."Template Type");
Greetnings BartD
I doubt your request has been solved by BartD's answer, unless you found out the correct syntax yourself. The correct syntax for a filter expression using alternatives (OR operator) uses the pipe symbol, not the semicolon.
Furthermore, don't use integer representation for option values if you can avoid it. It produces unreadable code. Furthermore I recommend to always insert values into filter expressions by using the value parameters. Thus, your setfilter statement should look similar to the following: In this statement, the filter expression expects the option captions. So there is no way to write rugged and readable code without the value parameters. Also, do not use STRSUBSTNO to insert values into the filter string. STRSUBSTNO does not know about quoting your values for the filter expression, SETFILTER does.