Pages

Friday, April 20, 2012

Overloading functions in Lotusscript

At times I find it difficult with out the ability to over load functions in lotusscript. The following way just helped me do it. Since I dont do this often its like new to me every time I do this :)

Sub new(key As Variant)
     Select Case Typename(key)
     Case "STRING":
           your code for this type
     Case "INTEGER"

          your code for this type
     Case "NOTESDOCUMENT"
          your code for this type
     Case Else
         your code for this
End Select
We have to be wary about the usage of such functions though. One stuff that I found was Typename(Nothing) is object. I least expected that.

I dont think using overloaded functions in lotusscript is a time saver. As a matter of fact I found this and just dropped the idea of using it after trying to use it :P. Cos man..., it was a head ache to me. I couldn't have a dynamic parameter list like how we can do in javascript and definetly can't match the way we do it in java or C or C++ anyway.

So I felt crippled when using this idea. However, this must help in some scenarios. Hope you find this in one such case :)

Thursday, April 12, 2012

Issues adding document items dynamically through lotusscript - "Field is too large (32k) or View's column & selection formulas are too large"

I had a very tough time completing a particular job which involved huge amount of document data through lotusscript. I had to debug through thousands of lines of code which were scattered across multiple agents and script libraries. Honestly I got screwed. Not because of the volume of code I was going through but because of the limitation of the notes documents that wont accept summary data beyond a certain limit - roughly around 60000+ bytes, may be 64 K.

I encountered this because, I wanted to print debug statements to understand the flow and was going though a lot of problems in getting them accumulated in a single document. I tried splitting the data between sever different fields, appendItemValue, richtext etc.. But none seemed to help me as desired. It was then that I identified the forgotten concept of the summary and non summary items. My Research towards this concept gave me an answer with in seconds. I found the following in the ibm site.(lost track of the url :< )

The idea is to save the data to the document and make the items as non summary items. That was the simple answer to what I thought was a so very complicated problem
"Field is too large (32k) or View's column & selection formulas are too large"

Or, in a LotusScript agent the following error message corresponding to error code 4000 occurs:

"Notes error: Field is too large (32k) or View's column & selection formulas are too large"



description of this fix:

Notes/Domino 6.x and later have the following limits regarding Summary fields: 32k per field, 64k per document. Relative to memos: The limit for sending to individual names and locally expanded groups is 15k. In addition, the above restrictions still apply as regards other fields in the memo.

Except for rich text fields, fields are typically flagged as "summary" by default; you can change this with the NotesItem.IsSummary property, but it will be reset to the default if the document is edited using a form that contains that field. Non-text fields (numbers, date-times) are also summary fields, so these limits apply to them also.

Hope this helps :)