How to set a filter on an empty option string with C/SIDE?

PaLPiTaTioN
Member Posts: 55
In CSIDE, I try to use this code:
I try to set the right filter on the field "Gen. Posting Type" of the G/L Entry-table. This field is an option field with three options: Purchase, Sale and '' (empty). Can anybody tell me how I should refer to the empty option value in my code? I now use " " because it's the only way to get the report compiling, but it seems to me that this is not the correct way to set the right filter.
IF "VAT-Type".Nummer = 1 THEN GLE2.SETFILTER("Gen. Posting Type",'%1',"Gen. Posting Type"::Purchase) ELSE IF "VAT-Type".Nummer = 2 THEN GLE2.SETFILTER("Gen. Posting Type",'%1',"Gen. Posting Type"::Sale) ELSE IF "VAT-Type".Nummer = 3 THEN GLE2.SETFILTER("Gen. Posting Type",'%1',"Gen. Posting Type"::" ");
I try to set the right filter on the field "Gen. Posting Type" of the G/L Entry-table. This field is an option field with three options: Purchase, Sale and '' (empty). Can anybody tell me how I should refer to the empty option value in my code? I now use " " because it's the only way to get the report compiling, but it seems to me that this is not the correct way to set the right filter.
0
Comments
-
but it seems to me that this is not the correct way to set the right filter.
PaLPiTaTioN, it`s absolutely correct way0 -
Another variant is to do like this:
GLE2.SETFILTER("Gen. Posting Type",'%1', 2);
Of course this code is correct only if OptionString for GLE2."Gen. Posting Type" is: Purchase, Sale,' '.0 -
the optionString is:
,Purchase,Sale
Mention the comma before Purchase, this one defines the empty value.0 -
By the way, in the code I supplied, the third filter is set to
" "
. the double quote normally defines a database field, so the compiler should expect a field, though I mean to set an empty string.0 -
why dont u use this :
GLE2.SETrange("Gen. Posting Type",0);
0 -
Of course! I learned not to use this type of coding, but in this case it takes away the problem. And 0 is the first entry in the OptionString so you're absolutely right.0
-
Jea, is your problem now solved or do you have any more0
-
i've got so many problems, but I won't disturb you with all of them :twisted:0
-
The first code example is the correct way to filter on an option field but you have to replace SETFILTER with SETRANGE and remove the %1.
IF "VAT-Type".Nummer = 1 THEN GLE2.SETRANGE("Gen. Posting Type","Gen. Posting Type"::Purchase) ELSE IF "VAT-Type".Nummer = 2 THEN GLE2.SETRANGE("Gen. Posting Type","Gen. Posting Type"::Sale) ELSE IF "VAT-Type".Nummer = 3 THEN GLE2.SETFILTER("Gen. Posting Type","Gen. Posting Type"::" ");
Nelson Alberto0 -
and probably not usring
" "
", but''
0 -
No, you have to use " " with only 1 space.Nelson Alberto0
-
If it compiles it is OK.
And remember: Whenever there are spaces in "object qualifier" (variable name, field name, option value name...) object qualifier must be enclosed with double quotes.
(one of the reasons why variable names are witohuot spaces, is that the code is more clear...)®obi
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯0 -
Hallo,
You can type
GLE2.SETFILTER("Gen. Posting Type","Gen. Posting Type"::"0");
in the C/AL-Editor and the compiler converts this to
GLE2.SETFILTER("Gen. Posting Type","Gen. Posting Type"::" ");
if the optionstring is
,Purchase,Sale
br
Josefbr
Josef Metz0
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