Hi, When ever I do a FORMAT on an option-field, I get the formatted value of the option-caption. If I need the formatted value of the actual option-value (not the underlying integer-value), has anybody any ideas on how to do that? Currently I work around my problem, by defining a variable, which contains the same option-values as my field, but not the various option-captions. Then I set this variable to be the same value as my field, and finally I format the variable instead of the field. But I wondered if there is anyway to retrieve the option-value directly in the FORMAT-command? regards Alexander
Try Integer := Format(OptionString,0,9) Let me know if it works! I’ve tried it my end and it seems too. Thanks Tony
Hmmm … FORMAT does not provide such a feature … would it be an option to set the language temporarily to ENU (if it’s e.g. a report)? What are you doing with the values?
quote:
Integer := Format(OptionString,0,9)
FORMAT allways returns a TEXT, not INTEGER … !?
[Oops!] Mis-understood the question! [Duh!] Trying to read the question, talk on the phone and sort out bods at the same time!
Try to assign a value to your option: optionVariable := optionVariable::; MESSAGE(‘Optionvalue is “%1”’,optionVariable); If you state MESSAGE(‘Optionvalue is “%1”’,optionVariable::); - you will get “1”
quote:
Try to assign a value to your option: optionVariable := optionVariable::; MESSAGE(‘Optionvalue is “%1”’,optionVariable); If you state MESSAGE(‘Optionvalue is “%1”’,optionVariable::); - you will get “1”
[8D] I think another missunderstanding … If understood right, Alexander has this problem: You have a field, type OPTION, e.g. “Document Type”. The OPTIONSTRING is (short) “Quote,Order,Invoice”, the OPTIONCAPTION is “ENU=Quote,Order,Invoice” “DEU=Angebot,Auftrag,Rechnung” If the language is set to DEU, FORMAT(“Document Type”,0,‘’) will return e.g. “Angebot” - but Alexander needs to receive “Quote” … He does not want to receive the VALUE like FORMAT(“Document Type”,0,‘’), e.g. 0 (Quote/Angebot)
Hi again, Thanks for Your replies. Joerg: You asked for the purpose… The option-value is “translated” into a dimension-value. In this case I must have the formatted option-value, and not the option-caption, because I otherwise have to have “duplicates” of any of the individual dimension-values under the dimensiontype in question. I also thought of the posibility of changing the language, but because the “translation” happens in a Code-Unit, I only can change GLOBALLANGUAGE. (Var: CurrGlobLang is defined as an Integer) // Globallanguage is set to Danish (1030) for the correct retrieval of Dim. CurrGlobLang := GLOBALLANGUAGE; IF CurrGlobLang <> 1030 THEN GLOBALLANGUAGE := 1030; Code(); // If nessesary Globallanguage is set back to original IF CurrGlobLang <> 1030 THEN GLOBALLANGUAGE := CurrGlobLang; But I didn’t like this, because the user actually sees the changing of language, and I am pretty sure that my customer will comment on it. Alexander
You are absolutely right Joerg… Didn’t see Your latest reply
Here you have two options,
- As a standard function to use everywhere (and use it to get different info type from a field) f_txtGetFieldInfo(p_TableId : Integer;p_FieldNo : Integer;p_Info : ‘OptionString’) : Text[1024] VAR l_RecordRef RecordRef l_FieldRef FieldRef l_Text_001 ‘Not a valid information type (%1).’ l_RecordRef.OPEN(p_TableId); l_FieldRef := l_RecordRef.FIELD(p_FieldNo); CASE p_Info OF p_Info::OptionString: EXIT(l_FieldRef.OPTIONSTRING); //Other options ELSE ERROR(l_Text_001, p_Info); END You call it this way (supose in the Item Card) MESSAGE(‘The selected option is: %1’, SELECTSTR(“Costing Method” + 1, f_txtGetFieldInfo(DATABASE::Item, FIELDNO(“Costing Method”), 0)));
- As a local code (supose again Item Card) VAR l_RecordRef RecordRef l_RecordRef.GETTABLE(Rec); MESSAGE(‘The selected option is: %1’, SELECTSTR(“Costing Method” + 1, l_RecordRef.FIELD(FIELDNO(“Costing Method”)).OPTIONSTRING));
Hope this helps.
Hey Jesús, Works perfectly. Thanks a lot. regards