Comparing Option integer values

davidec
Member Posts: 63
Hello!
I'm using NAV 4.0, SP1 and I have to change a report, to include only some lines which meet certain conditions. I'm working in the OnAfterGetRecord() trigger and I'm having problems with one of the rules I have to check.
I have to check the "G/L Account"."Account Type" field, in order to determine if the current record is Begin-Total. The application language is set to Italian, but I need the report to work even if the language were English, so I thought I could compare the "Account Type" integer value: how can I do that? :shock: Or is there a better/simpler solution to my problem?
You've probably guessed I'm a newbie and you're right, so please, if you know how to do that, could you add some code, please?
Thank you very much for your help!
I'm using NAV 4.0, SP1 and I have to change a report, to include only some lines which meet certain conditions. I'm working in the OnAfterGetRecord() trigger and I'm having problems with one of the rules I have to check.
I have to check the "G/L Account"."Account Type" field, in order to determine if the current record is Begin-Total. The application language is set to Italian, but I need the report to work even if the language were English, so I thought I could compare the "Account Type" integer value: how can I do that? :shock: Or is there a better/simpler solution to my problem?
You've probably guessed I'm a newbie and you're right, so please, if you know how to do that, could you add some code, please?
Thank you very much for your help!
1
Comments
-
Internally, Navision operates with option values as integers.
"Account Type"::"Begin-Total" is actually represented as "Account Type"::"0" internally - you can also write it like that when coding, it will automatically be converted into the corresponding OptionString text.
What this means is that if you change the OptionString for the field it will automatically change in your code as well.
Navision will always use the OptionString to represent the option value, never OptionCaption or OptionCaptionML. Therefore you'll have no problems dealing with different languages.Brian Rocatis
Senior NAV Developer
Elbek & Vejrup0 -
WOW GRAZIE Mille!
Thank you very much, it worked...
I didn't know operator ::0 -
read carefully rocatis post, too(he explains the logic, too)...things to know about options fields are not only '::' operator...
also you will note that after saving the object, if you review your code, the number you wrote as the option, is automatically transfomed in the correspondent value in the option string...0 -
Belias wrote:read carefully rocatis post, too(he explains the logic, too)...things to know about options fields are not only '::' operator...
also you will note that after saving the object, if you review your code, the number you wrote as the option, is automatically transfomed in the correspondent value in the option string...
And same thing work for REPORT::"125" and FORM::"123" and DATABASE::"123"... ;-)0 -
that's a cool little trick. I didn't know it worked for the Navision objects as well...but I guess it makes sense!0
-
Yes I've used it when dereferencing option values of a field before...just not those internal Nav objects (like form, report, etc.).
However one thing about your example:"G/L Account"."Account Type"::"B" also works
Note that if there are multiple option values with 'B' as the starting character it will pick the first one (I've had that bite me in the ass before) - so you have to make sure that you type enough of the word that there is only one choice for the compiler to make.0 -
kine wrote:Belias wrote:read carefully rocatis post, too(he explains the logic, too)...things to know about options fields are not only '::' operator...
also you will note that after saving the object, if you review your code, the number you wrote as the option, is automatically transfomed in the correspondent value in the option string...
And same thing work for REPORT::"125" and FORM::"123" and DATABASE::"123"... ;-)Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0
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