OptionString instead of OptionCaption in a Report
rwabel
Member Posts: 32
I want to display the value of the OptionString instead of the deafult OptionCaption in a Report. This means I've a field which I use in SourceExpr and it displays on my report the value in OptionCaption, but I would rather have the value from the OptionString. Is there a way to get the OptionString or to indicate which one should be used?
0
Comments
-
I don't think there is anything like that. It is strange though that your option captions are different from the option values. Why would you want to do that? And the next question is then why would you want to display the option value, if anywhere that the user uses that field, they see the caption. WOuldn't that be confusing?0
-
the option caption is different because I need in some cases text and in another one a value. For example
OptionString has the values 2,4,5
OptionCaption has the values text2,text4,text5
and then in OptionCaptionML are text2,4,5 in the other languages
In some forms I need the text, it's more obvious and more readable. In the report I must have the number and not the text.
Maybe there is another way to solve that problem. I hope I could explain in understandable
thanks for helping me out :-)0 -
If you can't get to the values, I'd try writing a little function on the table that returns a string representation of your option field, and put that function as the SourceExpr in your report. It's hard coded, but it does the trick.0
-
I'll give that a try, thanks
If there is another way, I would prefer that one. ;-)0 -
I came across this function and I get now all the values from the optionstring:
http://www.mibuso.com/forum/viewtopic.p ... tionstring
Is there a way to get the selected value from the OptionString field?0 -
Refering to the topic you posted try the following:
Create a function called GetOptionValueGetOptionValues(Tab : Integer;Field : Integer) : Text[200] BEGIN RecRef.OPEN(Tab); FRef := RecRef.FIELD(Field); OptVal := FRef.OPTIONSTRING; RecRef.CLOSE; EXIT(OptVal); END;
Variables in this part are:
RecRef: RecordRef
FRef: FieldRef
OptVal: Text 200
Then use the following code:EVALUATE(OptNo,FORMAT(FieldName,20,'<Number>')); Val:=GetOptionValues(TableNo,FieldNo); FOR i:=0 TO OptNo DO BEGIN Seperat:=STRPOS(Val,','); Result:=COPYSTR(Val,1,Seperat-1); Val:=COPYSTR(Val,Seperat+1,200); END;
The variables are:
Val: Text 200
Result: Text 100
OptNo: Integer
i: Integer
Seperat: Integer
FieldName is the option field you are using.
TableNo is the no. of the table, FieldNo the no. of the field.
As "result" you should receive the value of the option field instead of the caption. This should work! If not: ask again! :-)
[Edit: the option value is the option string. I mixed the words up. Sorry for that!]
Greetz
NicoleProTAKT Projekte & Business Software AG
Microsoft Dynamics NAV Partner
Bad Nauheim, Germany
http://www.protakt.de
http://twitter.com/protakt0 -
If you gave the first value 0 then 1 then 2, etc... you can also do this:
intOptionValue := "My Record"."My Option Field";
and print that integer (=intOptionValue).Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
@ngebhard: thank you very much for the reply. It's working fine now! I made a 2nd function and put the 2nd code and call now that function directly from the property in the report.
You are really my hero, I was very astonished that such a function doesn't exist already in navision.
@kriki: that would be a nice solution, but unfortunately the values aren't like that in my case. thank you anyway0 -
I've just noticed that I always get the same value :-)
I then analysed it with the debugger and found out that
OptNo is always 0!EVALUATE(OptNo,FORMAT(FieldName,20,'<Number>'));
I have a table VarJnlLine and the filed Correction Code with the number 140
I call the function now:...FORMAT(VarJnlLine."Correction Code",20,'<Number>'));
is that wrong?
I've also tried with the FILEDNAME function:FieldName := VarJnlLine.FIELDNAME("Correction Code");and then use your function, but then I get an error that anincorrect field or attribut was defnied in the Format property. <NUMBER>
Either I've wrongly interprete your code or there must be some kind of a mistake in the code.
thanks0 -
I became different results when I tried it. Do you wanna send me your report? Just send me an email, I will have a look at it.
Greetz
NicoleProTAKT Projekte & Business Software AG
Microsoft Dynamics NAV Partner
Bad Nauheim, Germany
http://www.protakt.de
http://twitter.com/protakt0 -
Should I export it to a txt or fob file? do you need the table too?
thanks0 -
I think we'vo got it!
One more thing if someone is interested in:
if the function gets the last option, there was an error with the COPYSTR caused by the missing comma! I changed the coding:FOR i:=0 TO OptNo DO BEGIN Seperat:=STRPOS(Val,','); IF Seperat<>0 THEN BEGIN Result:=COPYSTR(Val,1,Seperat-1); Val:=COPYSTR(Val,Seperat+1,200); END ELSE Result:=Val; END;
Now it is supposed to work!
Greetz
NicoleProTAKT Projekte & Business Software AG
Microsoft Dynamics NAV Partner
Bad Nauheim, Germany
http://www.protakt.de
http://twitter.com/protakt0 -
thx, helped me a lot and saved time
0 -
great! this helped me as well.
in our case, we have a need to interface with a 3rd party warehouse management system. we need to send something called an NMFC code to the WMS. In Navision, we want friendly names like Plastic Parts, Cardboard Parts, etc., but we want to send the numeric equivalent to WMS (156600, 152660 respectively in this example). By using this, i can have an option presenting the friendly name in Navision, but send the actual option value to WMS.
Thanks! \:D/kind of fell into this...0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K 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
- 323 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

