Domino Code Fragment

Code Name*
How do you remove an element from a Textlist field?
Date*
04/29/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.18.227.102.225
Description*
How do you remove an element from a Textlist field?
Type*
LotusScript
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
Files/Graphics attachments (if applicable): Code:
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