Wednesday, February 27, 2013

How do we find the size of a rich text field in Lotus Notes?

I am facing an issue, Its peculiar but still IBM is not fixed this issue,

My database is very old. It is created on 1998. Now my database's version is 6.5.1. So my case everything has its own limit. After a long time, I seen like my db usage is 98% after the completion of compacting. So whenever my document exceeds 32K it can be old or new, the document became spam. Like we can not access the document. We can not open the document. We can not see the property of the document. I had some agents that will take all the documents one by one. Because of this issue, the agent stopped and thrown the error like "field is too large 32k or view's column & selection formulas are too large". I could not find the reason why it is happening.

eg:- If my already existing document has more than 32k of size. I have gone and edited the document. And saved it. The document size exceeds 32k, and it became spam what I mentioned above. If my new document exceeds 32k, I attained the same issue.

I was confused. I tried the following steps.

1. I changed the Text to Summary for all items. Nothing happened.
2. As of Notes constraints, document can have any number of size less than 64GB(about db size). But less than 6 It has some limitation. I guess. Sorry if it is wrong. Number of field should not exceed 3000. So I checked the document size. And tried to reduce that. I deleted contents of the fields and made the document to less than 64K. Same problem came.
3. I created a lot of field. The form had thousands of field. So I removed many field. I counted as a child and made it to 1000 exactly including reserve fields. Like $Revisions.  -  32K error. :(
4. I know that the limitation of RTF(Rich Text Field)  is 1gb. So I ignored.
5. I found the $UpdatedBy field is exceeding 32K of size. So I limited the number of entries for this.

Finally, I found that the issue from Rich text field. I deleted the attachments and reduced the document size less than 32k. and saved it. I got satisfied.

So I planned to restrict the document size to the user. I want to avoid the 32K error in future documents. Better I can stop the attachment size should not exceeds 15k. So I want to fetch the size of the RTF. I found the better solution for that. t refers NotesRichTextItem.

        Set t = doc.GetFirstItem("body")
Dim newdoc As NotesDocument
Set newdoc = db.CreateDocument()
Call t.Copyitemtodocument(newdoc, "reasonType")
Msgbox newdoc.Size

Also I can count the current document size. One funny thing is, our Notes rich text field contents like copy and pate images not an attachments can not be taken without saving the document.

Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Set uidoc = ws.CurrentDocument
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim t As Variant
Call uidoc.FieldSetText("SaveOptions","0")
Call uidoc.Save()
Set db = session.CurrentDatabase
Set doc = uidoc.Document
        msgbox doc.size

But my question to IBM, Why the hell this much big issue can not be solved?

Once the 32K error document has been created then we have to delete the replica copy and take a new replica copy from the source server. This is the only solution for deleting the 32K error documents. You can not delete these document manually.