HTML5, CSS3, jQuery, JSON, Responsive Design...

Getting around the 15k limit

Michael Brown   January 21 2011 12:47:46 AM

I had some script that was attempting to pull some text data from Notes Rich Text field. The data is more than 15K in size, hence using a Rich Text rather than a plain text field. But whatever I tried, I was only getting the first 15K (I presume) of data returned in the script.

I could see in the doc properties that there were two fields there with the same name; this is what Notes does with the larger-sized Rich Text fields: it splits them into multiple "fields" all with the same name.   But I was only able to get a handle on the first one of these "fields" with my LotusScript.   GetFirstItem returned the first one only (der, I guess that's why the call has "First" in its name!). NotesDocument.items returned an array of *all* fields on the document, but when I looped though the array of fields, I only ever got one instance of my Rich Text field.  I tried using GetFirstItem followed by Remove followed by another GetFirstItem, but the call to Remove removed *all* of the field entries with that name as they appeared in the doc properties, so the second call to GetFirstItem always came up empty.

Thankfully, I found a post on the Developer Forums from a  Matthias Brockhoff and it seems that you can do this by way of the NotesRichTextNavigator and NotesRichTextRange classes.  I've turned this code into the LotusScript function below, although the code is almost unchanged from Matthias' post, so all credit to him.

Function getAllTextFromRTField(doc As NotesDocument, fieldName As String) As String

   Dim RText As NotesRichTextItem
   Dim RTNav As NotesRichTextNavigator

   Dim RTRange As NotesRichTextRange
   Dim count As Integer
   Dim TextString As String

   If doc.HasItem(fieldName$) Then
           Set RText = doc.GetFirstItem(fieldName$)
           If (RText.Type = RICHTEXT) Then
                   Set RTNav = RText.CreateNavigator
                   Set RTRange = RText.CreateRange
                   If RTNav.FindFirstElement(RTELEM_TYPE_TEXTPARAGRAPH) Then
                           count% = 0
                                   count% = count% + 1
                                   Call RTRange.SetBegin(RTNav)
                                   TextString$ = TextString$ + RTRange.TextParagraph
                           Loop While RTNav.FindNextElement(RTELEM_TYPE_TEXTPARAGRAPH)
                   End If
           End If
   End If
   getAllTextFromRTField = TextString$
End Function

Goodbye 15k limit!!!

1Brent Henry  01/21/2011 9:02:35 AM  Getting around the 15k limit

When you had the 15k problem were you using the GetUnformattedText or GetFormattedText methods of NotesRichTextItem?

The Text property might have a limit because it is inherited from NotesItem but I've never had a problem using the other two.

2Mike Brown  01/21/2011 1:42:49 PM  Getting around the 15k limit


I can't remember if I tried those two or not. I will test them next week though.


- Mike