Field-level LotusScript

I’ve searched through this forum and the Notes 4/5 forum but I can’t find an example anywhere.

How do you use field-level LotusScript?

When I write code in the Initialize event of a field, how do I write the results of my calculations to that field before the document is displayed? I realize this can be done through agents, QueryOpen, PostOpen, etc. but in this particular case those options would be far more complicated than being able to do it right in the field.

I’ve tried something like:

Set uidoc = workspace.CurrentDocument

Call uidoc.FieldSetText(“TimelineChoices”, choices)

But the workspace object doesn’t actually have a “CurrentDocument” property at the time that the field Initialize action is triggered.

Does anyone have actual sample code of how to do this? Any help would be greatly appreciated!

Luis.

Subject: RE: Field-level LotusScript

You can’t do this the way you’re wanting to do it.

The way to initialize a field value is with the field’s Default or Value formula.

If the field already has a value that you want to overwrite, or if the code can’t be written in macro language, then you must use the Queryopen form event.

Subject: RE: Field-level LotusScript

Hi Andre, thanks for your reply.

I have actually begun to break apart what I was trying to do so that it can be written in formula language.

That aside, when would you use the Initialize event at a field level? Is there any valid LotusScript that you could actually put there? It seems odd that fields would even have that event if there’s no way to use it.

L.

Subject: RE: Field-level LotusScript

I personally have never had occasion to use the Initialize event for a field, and I don’t know whether anyone else has.

It’s there because every LotusScript Object has an Initialize and a Terminate event. It’s a simple rule, and we like rules without exceptions, even if it sometimes means there are bits of functionality that aren’t especially useful. In other types of LotusScript objects, the Initialize event is very useful.

Subject: Field-level LotusScript

Why would putting the code in the queryopen or postopen be “far more complicated”? You are accessing the same objects.

JLT