Was woundering if there was a Formula version of this solution in the link below?http://www-10.lotus.com/ldd/nd6forum.nsf/55c38d716d632d9b8525689b005ba1c0/3ae9f77dd508c9148525714d0039e161?OpenDocument
Although I want the reverse to happen. That is, I am trying to access the Keyword (not the synonym) for display elsewhere using formula.
For example, I have a combobox Field (named Preference) with: First Choice | 1 as a value.
I have another text field trying to display “First Choice” but when I access the Preference field using formula it just returns the synonym “1”. How do I get it to display “First Choice” using formula?
Subject: Displaying the Keyword (NOT the Synonyms)
Thank you for all for your responses and help!!!
Maybe I did misconstrue the indented use of Keyword Synonyms in a combo field but I simply wanted a way to display the UI value of the field in @Formula and not what was stored in the back-end. This is definitely achievable with LotusScript but I would have to rewrite too much code to justify the time required to convert my entire Formula to LotusScript do so, but I did find a work around.
…I wanted to keep maintenance on the Form easy, so Esther’s first post (hard coding the values with an @If statement in the second field) wasn’t the direction I wanted to go, but thank you for clearing up what I was fearing.
…I didn’t get Harkpabst’s post in time (creating a third field as a data container with all the values and using @Left & @Right to parse out the values accordingly). NOTE: when I have to do this again, that’s the route I will take — THANKS Harkpabst!!!
To dynamically set a field (named “FormType”) to the UiDoc value of my combobox, I did the following in the “OnChange” event of my ComboBox named “Preference”…
Sub Onchange(Source As Field)
Dim session As New NotesSession
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim Preference As String
Set uidoc = workspace.CurrentDocument
Preference = uidoc.FieldGetText( "Preference" )
Call uidoc.FieldSetText( "FormType", Preference )
End Sub
I didn’t achieve my goal of keeping it all in formula (so as to not rewrite all my existing code), but as it turns out I didn’t need to. Thanks again for the help, if you see any problems with what I did please chime in.
Subject: Displaying the Keyword (NOT the Synonyms)
You have to code it. Keyword synonyms are only used to allow you to display a value in a field, but have it actually save a different value. If you’re trying to display the results of that in a different field, you need to code in all of your choices.
So the formula for the second field would be something like this:
@If(firstField=“1”; “First Choice”; firstField=“2”; “Second Choice”; “”)
Subject: RE: Displaying the Keyword (NOT the Synonyms)
Doesnt that completely defeat the purpose of using synonyms in the first place (Hard Coding)? So if I go back and need to change “First Choice” to “1st Choice” — I would have to update it in both places?
Subject: RE: Displaying the Keyword (NOT the Synonyms)
You have apparently misunderstood the reason for aliases altogether. The point is that the value stored in the field ALWAYS means the same thing to the application, but the values displayed to the user can change depending on circumstances. In a unilingual application, this might not seem like a very big deal, but think about multilingual applications (or even localising a database design to another language).
In a multilingual application, you store, say, a “1” or a “0”. On the English form, they may represent “Yes” and “No”, in French, “Oui” and “Non”, and so on. All that needs to be language-specific are the display keywords – all of your Formulas and LotusScript can be shared among the language-specific forms (which will normally have the same alias and be hidden from all but the target language).
Subject: RE: Displaying the Keyword (NOT the Synonyms)
To the best of my knowledge (which admittedly has gaps), synonyms are intended to allow you to display a label in ONE field and save a different value IN THAT SAME FIELD. So if you have a whole bunch of funky part numbers that your systems require, but your users only know the items by part name, you can set up a dialog list/combobox to display one value to the user but save another value for the system. This doesn’t have any affect on other fields you may use the field name in - if you compute field 2’s value to be "Item name " + field1, it’s going to display the value that is SAVED in field1 on the document, not the value that displays.
Look at the Designer Help file “Creating aliases for choices in a list” - it’ll tell you exactly the same thing.
Subject: RE: Displaying the Keyword (NOT the Synonyms)
Right, that’s what synonyms are for. However, the definition of the list of synonyms doesn’t have to be literally in the field itself. If I need to access both, the “label” and the “value” part in one form, I usually create one hidden field to hold a list like
“Label A | A” : “Label B | B” : “Label C | C”
The name of that field can go as a formula into the list field definition. Using e.g. @Left and @Right (which happily work on lists) it is very easy to split that into one list of labels and one list of values. Once you know, which element was picked in the list field, the corresponding value of the label list can be retrieved.
Depending on what is needed, variations of that pattern can be used. Just hope I got Jeremy’s problem right.