Domino Code Fragment

Code Name*
Using Lists in LotusScript
Date*
04/28/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.3.149.233.72
Description*
Lists are very powerful in LotusScript. You can use a list to get a multi-value field from a document and add the values to a list (thus ensuring uniqueness). You can then process many documents against the same list and when you are done, you will have a list of all of the values which appeared at least once in the set of documents you processed.
Type*
LotusScript
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
Files/Graphics attachments (if applicable): Code:

Dim itemArray As Variant
Dim itemList List As Integer


itemArray = doc.someItem
Forall n In itemsArray
itemList(n) = 1
End Forall


To store a list where you are using the labels as values (as in the example above) back into a document, create an array:

Dim i As Integer
Dim itemList List As Integer


'First size the array
i = 0
Forall n In itemList
i = i + 1
End Forall
Redim nameList(i) As String


'Next convert the labels to values in the array
i = 0
Forall a In itemList
nameList(i) = Listtag(a)
i = i + 1
End Forall


'Save the array as a text list
doc.someMultiValueItem = nameList


You can do other interesting things with lists to handle the often dynamic nature of Domino data. One example is to create a list of lists:

Dim DatesShipped List As Variant
Dim NumberOfCrates List As Integer


Then your DatesShipped labels are text values of dates and the list values are lists where the NumberOfCrates label is a fruit type and the list values are how many crates where shipped. This can result in a data structure often wanted but difficult to create in views or forms. With each document you process, simply check to see if the date is alredy in the list, and if the fruit type is already in the list and add to it. Otherwise, create a new list entry. Here's what a populated list of lists would look like:

01/01/99
Bananas = 5
Pineapple = 2
Apples = 6
01/02/99
Mangos = 8
Pineapple = 1
Oranges = 12
01/03/99
Apples = 4
Oranges = 2