Lotus Notes FAQ Visit Our Sponsor!

How do you remove an element from a Textlist field?

You can use the LotusScript Evaluate function to run the Notes V3 version of this FAQ. If you prefer a pure LotusScript version, this example takes a text list (tl1) with the values "Elem1":"Elem2":"Elem3" and turns it into "Elem1":"Elem3". You will have to do some fiddling with the Redim Statement to make sure that you have enough space (eg, the element you wish to remove is not in the list).

Dim db As NotesDatabase
Dim ws As New NotesUIWorkspace
Dim session As New NotesSession
Dim i As Integer
Dim j As Integer
Dim textList As Variant
Dim outList As Variant

Set uidoc = ws.CurrentDocument        ' get the current uidoc
Set doc = uidoc.Document              ' get the backend doc

textList = doc.GetItemValue("tl1")    ' Get the list and put it in a variant
Redim outList(Ubound(textList)-1) As Variant    ' Dim the outlist
j = 0
For i = 0 To Ubound(textlist)         ' Loop through and check for the element to be removed
  If textList(i) <> "elem2" Then      ' Check for the value to replace (could be a variable)
    outList(j) = textList(i)          ' Populate the outlist
    j = j + 1
  End If
Next
Call doc.ReplaceItemValue("tl1",outList)        ' replace the original
list with the outlist
Call uidoc.Reload                     ' reload the UIDoc with the new backend values


Applies to Notes Versions: 4
4.5
4.6
5
Last Modified: January 19, 1997