Notes Item/Field size limitation

In LotusScript, when using NotesItem AppendToTextList method to build a UNID list, the maximum number of UNIDs a NotesItem can hold is 964, which is about 30848 bits (32-bit UNID * 964). The 965th UNID that is appended will give an error of cannot append text to a null item. An actual field on a NotesDocument probably can only contain 16K, so the number of UNIDs can be put in a field is much smaller.

If you have to put more UNIDs in a field on a document, multiple fields would have to be used. A sample code of dynamically writing into multiple fields and dynamically reading from possible multiple fields shown below.

'Dynamically write to multiple fields

Dim numUnids As Integer
Dim unidArray As Variant
Dim arrayItem As NotesItem
Dim fieldNum As Integer
Dim fieldName As String
Dim i As Integer
Dim doc As NotesDocument

'set the limit of the number of UNIDs a field can contain to 400
fieldUnidsLimit = 400 

fieldNum = 1
numUnids = 0

'references is a list of UNIDs we got in memory by early processing
Forall x In references
  'count the total number of UNIDs
  numUnids = numUnids + 1
End Forall

If numUnids <= fieldUnidsLimit Then
  'the number of UNIDs need to store on the document is less than the limit 
  'use a single field-DocRefs field to hold the UNIDs
  doc.DocRefs = references
  'the number of UNIDs need to store on the document is greater than 
the limit, need to dynamically create more fields to hold the UNIDs, the field name would be used are DocRefs1, DocRefs2 ... 'Redim sets first element as index 0, so need to redim to the limit minus 1 Redim unidArray(fieldUnidsLimit-1) As String For i = 1 To numUnids 'fieldUnidsLimit*(fieldNum-1) calculates the number of Unids that have been put on the doc unidArray(i-1-fieldUnidsLimit *(fieldNum-1)) = references(i-1) If i = fieldUnidsLimit * fieldNum Or i = numUnids Then 'a field is full or we reach the end, put the array on the doc,
erase the array, and prepare for the next field fieldName = "DocRefs" & Cstr(fieldNum) Set arrayItem = doc.ReplaceItemValue(fieldName, unidArray) Call doc.Save(True, True) If i < numUnids Then 'more fields needed, increment fieldNum for next field fieldNum = fieldNum + 1 'empty the array and reDim for the next field Erase unidArray If (numUnids - i) <= fieldUnidsLimit Then Redim unidArray(numUnids - i - 1) Else Redim unidArray(fieldUnidsLimit - 1) End If End If End If Next End If '*************************** 'Dynamically read from possible multiple fields Dim fieldName As String Dim fieldNum As Integer Dim arrayItem As NotesItem If doc.DocRefs(0) <> "" Then 'this is the case there is only one field 'do operations here...... Else 'If the DocRefs is not on the doc, we know there are mutiple fields of that fieldNum = 1 fieldName = "DocRefs" & Cstr(fieldNum) While doc.HasItem(fieldName) Set arrayItem = doc.GetFirstItem(fieldName) 'do operations here...... fieldNum = fieldNum + 1 fieldName = "DocRefs" & Cstr(fieldNum) Wend End If

This was first published in May 2002

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.