Field Option Value

Fisherman
Member Posts: 456
Question about Option Values.
I'm trying to retrieve the selected option value as a text from a table that I've created. I found three methods and functions that I'm trying to put together to do this, but I don't think I've got it right.
I found the SELECTSTR function, which says it allows you to pull an indexed item from a comma separated list. I then found in the description of the Option type that the FieldRef will return a numeric value representing the item in the list that was selected, and then the OPTIONSTRING method, which supposedly returns the option string associated with the field. I tried combining them like so...
It's telling me that this is not valid syntax...
Does anyone know how to do this?
I'm trying to retrieve the selected option value as a text from a table that I've created. I found three methods and functions that I'm trying to put together to do this, but I don't think I've got it right.
I found the SELECTSTR function, which says it allows you to pull an indexed item from a comma separated list. I then found in the description of the Option type that the FieldRef will return a numeric value representing the item in the list that was selected, and then the OPTIONSTRING method, which supposedly returns the option string associated with the field. I tried combining them like so...
textValue := SELECSTR(rec."Option Field",rec."Option Field".OPTIONSTRING)
It's telling me that this is not valid syntax...
Does anyone know how to do this?
0
Comments
-
try :
textValue := FORMAT(rec."Option Field");
An option in reality (=in the DB and also how to use it) is an 0-based-integer. So the first option=0, the second option=1, and so on.
If you want the string of the option, you have to use it like above.
If you want to test if an option has a value, or put a value in it, you should do this:rec."Option Field" := rec."Option Field"::"Some Option".
It is possible to put rec."Option Field" into an integer-field and an integer field into an option. So if you need to pass an option to a function as a parameter, in the function you can receive it as an integer and then use that integer in the function. An example:Function SomeFunction(intDocumentType As Integer) BEGIN IF LrecSalesHeader."Document Type" = intDocumentType THEN ... END;
And to call it:SomeFunction(recSalesHeader."Document Type")
Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
Great Explanation.
Thanks Kriki!0 -
If you want the numeric value, simply create a variable of type Integer and assign the option field to it like this i := rec."optionField"; You can then use the Format(i) to convert the int to a string
If your want the option field text represented by the option value use this syntax: FORMAT(rec."yourOptionField");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