Manage Learn to apply best practices and optimize your operations.

Add Nearly Unlimited Text List Data to a Form

This function will add string text to a set number of fields on a form. The function allows you to set the limit of entries per field, as well as the number of fields per form.

You may have noticed that the "AppendToTextList" slows as over 100 entries are made in a single field. This way, you can add thousands of entries if desired. Duplicates are not added. Caveat - watch the number of fields and the field names, otherwise the UNK table may fill up and the database can be corrupted. However, this usually takes about 3000 field names in the database to occur, and many more (15,000+) in R5.
Function AddToFieldsList( doc As NotesDocument , FieldName As String ,
StringValue As String , _
NumPerField As Integer , NumFields As Integer ) As Variant

' This routine will add a StringValue to a series of FieldNameX items in a
' FieldName0 will contain up to NumPerField entries before FieldName1 is
' Result is True if the item was added, false otherwise.

On Error Goto ErrorOccured
Dim fldnum As Integer, foundit As Integer, tmpPosition As Integer, FieldNumber
As Integer
Dim tmpitem As NotesItem

AddToFieldsList = False
foundit% = 0
' First, search for the value in any of the current fields.
For fldnum% = 0 To NumFields%
Set tmpitem = doc.GetFirstItem( FieldName$ & Cstr( fldnum% ) )
If Not ( tmpitem Is Nothing ) Then
FieldNumber% = fldnum%
tmpPosition% = 0
' Double check that the field is not there but blank...
If tmpitem.Values( 0 ) <> "" Then
Forall itmvals In tmpitem.Values
If Ucase$( Trim$( itmvals ) ) = Ucase$( Trim$( StringValue$ ) ) Then
foundit% = 1
Exit Forall
End If
tmpPosition% = tmpPosition% + 1
End Forall
' The field was there but blank.
Exit For
End If ' Field was blank...
' tmpitem is nothing...
Exit For
End If
If foundit% = 1 Then Exit For
' Now, we add the data if needed.
If foundit% = 0 Then
If FieldNumber% <= NumFields% Then
' We can still add more fields or values to this field.
If tmpPosition% < NumPerField% Then
' We can add to the current field. Do so.
Set tmpitem = doc.GetFirstItem( FieldName$ & Cstr( FieldNumber% ) )
' It is possible that this field does not exist yet.
If tmpitem Is Nothing Then
Set tmpitem = doc.ReplaceItemValue( FieldName$ & Cstr( FieldNumber% ) ,
StringValue$ )
AddToFieldsList = True
tmpitem.IsSummary = False
Call tmpitem.AppendToTextList( StringValue$ )
AddToFieldsList = True
End If
Elseif FieldNumber% + 1 <= numFields% Then
' The current field is full. Create a new one.
Set tmpitem = New NotesItem( doc , FieldName$ & Cstr( FieldNumber% + 1 ) ,
StringValue$ )
AddToFieldsList = True
tmpitem.IsSummary = False
' We are full. No more can be added.
AddToFieldsList = False
Exit Function
End If ' The current field is empty.
' We are full. No more can be added.
AddToFieldsList = False
Exit Function
End If ' Where to add this item in the fields.
Else ' foundit% = 1
' File was found in the list, DO NOT mark it as an add.
AddToFieldsList = False
End If ' File was found

Exit Function
Messagebox "ERROR! - " & Error() & " (" & Cstr( Err() ) & ") Line:" & Erl()
Exit Function
End Function

Dig Deeper on Domino Resources - Part 2

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.




  • iSeries tutorials's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...