How can we deal with field size limits?

According to the 8.5.1 documentation for the NotesItem.AppendToTextList method, a text list field should have a size limit of 64K. Checking the help documents in releases prior to 8, no size limit is listed - are we to assume 32K, the normal limit for text fields?

How can you tell ahead of time if your data will fit? It has been my observation that the encoding used varies - how can you determine in LotusScript if single, double, triple, or ??? byte encoding will be used?

One way to test if the data will fit is to repeatedly call NotesItem.AppendToTextList() until it throws an error. However, the error thrown might be 4000, might be 4360, or maybe no error will be thrown in the code at all and Notes will complain directly to the Notes client:

“Field is too large (32K) or View’s column & selection formulas are too large”

Also, AppendToTextList() is annoyingly slow - hundreds of successive calls to it will cause quite a delay in the Notes client.

All of these issues make it very difficult to deal with data that borders on or exceeds the field size limit.

Subject: NotesItem properties

The trick to the size of a text item is the IsSummary property. If false, the NotesItem can be up to 64K. If true, only 32KB. Read the help docs for other implications of setting it to false.

You can test for the size of the item with the ValueLength property (rather than waiting for the client to throw an error).

You can also use a rich text field instead of text for your text data. Rich text fields have no size limit…just a very large limit to the number of paragraphs.

Subject: Re: NotesItem properties

"The trick to the size of a text item is the IsSummary property. If false, the NotesItem can be up to 64K. If true, only 32KB. Read the help docs for other implications of setting it to false."Thanks for the info! I was not aware of this. Out of curiosity, how do you know this? I couldn’t find it referenced anywhere in the help.

“You can test for the size of the item with the ValueLength property (rather than waiting for the client to throw an error).”

ValueLength is only useful if your data actually fits and you’ve already written it to the item - I need to know ahead of time if my data will fit, so I can trim it if necessary. Unsure of how to try and count bytes (in my testing, Notes uses variable encoding for text data stored in a field, and I’m not sure how to predict what encoding will be used), the only way I could think of to figure out if the data would fit was to just keep adding values until I ran out of values or raised an error.

Subject: try LenB

Have you had a look at the LenB function (length in bytes)? You can use it to test both the string you want to add, and/or the existing string field.

As to the ‘feature’ of IsSummary, you are right, I don’t see it in the help file. It’s one of those pieces of lore handed down from developer to developer. I found it when I faced a similar dilemma to yours, and I was searching through the forums for clues. Half of what I know about coding in Notes is from the help files, the other half is from these forums. Make sure to check the version 6/7 forum, too. Lots of information there that hasn’t been repeated in the newer forums.

Subject: LenB or LenBP?

My current solution is using LenB, though I’m not clear about whether it’s better to use LenB or LenBP.

I’m counting bytes of my string data using LenB, then adding some overhead I’ve observed from testing:

  • switching from single-value to multi-value text field incurs a 6-byte overhead

  • each additional value in a multi-value field incurs a 2-byte overhead

It seems to be working, thought I haven’t tested it thoroughly enough to ensure that I am actually squeezing in as many bytes as possible. I am at least not getting errors.

One side discovery has been that NotesItem.Values is atrociously slow for iteration if you have a large number of values. For a little over 900 values, iterating over NotesItem.Values is taking about 10 seconds. If I instead copy them all in one go to a variant (someVariant=item.Values), then it takes less than a tenth of a second to iterate over the values in the variant.