Table Filter in Report - OR Condition required

Chetan
Member Posts: 15
Hi All,
I am designing a report considering "Gen. Journal Batch" and "G/L Entry" tables.
I have Batch Name as link field between above tables.
I want to retrieve the records if Sub Type in "Gen. Journal Batch" be either "Cash Receipt Voucher" OR "Cash Payment Voucher" OR "Bank Receipt Voucher" OR "Bank Payment Voucher"
Could you please help with this. How can we apply the OR condition in the Table Filter ?
I am designing a report considering "Gen. Journal Batch" and "G/L Entry" tables.
I have Batch Name as link field between above tables.
I want to retrieve the records if Sub Type in "Gen. Journal Batch" be either "Cash Receipt Voucher" OR "Cash Payment Voucher" OR "Bank Receipt Voucher" OR "Bank Payment Voucher"
Could you please help with this. How can we apply the OR condition in the Table Filter ?
Chetan
Bangalore
Bangalore
0
Best Answer
-
Hi Chetan,
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:"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.1
Answers
-
Hey,
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 BartD1 -
Hi Chetan,
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:"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.1
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions