Using LotusScript, I want to get user input and append that input to a multi-value text field. I’m using InputBox$ to get the input as a String, and AppendToTextList to add this input to the field (which is a NotesItem).
This works fine when appending single values to the field. However, when attempting to input multiple values (separated by a semicolon, which is what the multivalue field is set to separate values on), the new input remains as a single value.
My guess is that I need to somehow break the input Sting into an array (parsing it on any semicolons), and then append the array to the field.
Is this a correct approach? If so, how do I do this? Can I append an array to the field in the same way?
NOTE: I’ve tried using Evaluate with @Explode, but I get a type mismatch when I try to assign this to a Variant (or maybe the problem is in passing a script variable to the @ formula?)…
Dim newValueArray As Variant
newValue$ = Inputbox$ ( “Enter the new values.”, “New Values” )
Set newValueArray = Evaluate( “@Explode(newValue$)” )
Subject: Parse String for multivalue field? (LotusScript)
Evaluate requires a NotesDocument as a method parameter.
Try something like:
Dim newValueArray As Variant
newValue$ = Inputbox$ ( “Enter the new values.”, “New Values” )
Set newValueArray = Evaluate( “@Explode(newValue$)”, NotesDocument )
Where NotesDocument is the current doc.
HTH
Shawn
Subject: RE: Parse String for multivalue field? (LotusScript)
Thanks, but I still get the type mismatch.
Note: It appears that the object (document) parameter for Evaluate is optional, unless the formula is accessing a field in the document. But in my case, the formula is using a String defined in the script.
Subject: Parse String for multivalue field? (LotusScript)
Dim ws As New NotesUIWorkspace Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim item As NotesItem
Dim userInput As String
Dim i As Integer
Dim newVals As Variant
Dim temp As String
Set uidoc = ws.CurrentDocument
Set doc = uidoc.Document
Set item = doc.GetFirstItem("YourItemName")
userInput = Inputbox("Add an item, or multiple items separated by semicolons")
newVals = Split(userInput,";")
For i = 0 To Ubound(newVals)
temp = newVals(i)
Call item.AppendToTextList(temp)
Next
Call doc.Save(True,True)
Subject: RE: Parse String for multivalue field? (LotusScript)
That works! I had forgotten about the Split function, and iterating through the array makes sense when appending values.
Thanks!