Home > Domino Tips > Developer > LotusScript > Notes Item/Field size limitation
Domino Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

LOTUSSCRIPT

Notes Item/Field size limitation


Long Yu
06.01.2002
Rating: -3.69- (out of 5) Hall of fame tip of the month winner


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


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.

Code

'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
Else 
  '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

Rate this Tip
To rate tips, you must be a member of SearchDomino.com.
Register now to start rating these tips. Log in if you are already a member.




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


RELATED CONTENT
LotusScript
How to clear a Lotus Notes local cache with LotusScript
Create a non-specified date picker with LotusScript code
LotusScript accesses clipboard to view copied Notes documents
LotusScript action button manages Lotus Notes mail files
LotusScript sorts a Lotus Notes document collection
Display Lotus Notes user group membership details in a tree view
Alternate version of @Command forwards subform via LotusScript
Process large arrays in Notes forms without undue coding or testing
How to use LotusScript to modify a Lotus Notes view selection
Display a custom message box using a LotusScript-generated button

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

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.



Domino & Lotus Notes Security Solutions: Authentication, Antispam, Encryption and Antivirus
HomeTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersDomino IT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 1999 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts