How can I expand/collapse individual sections programmatically on a form, using Formula Language or LotusScript?

I have a form (which will be used in the Notes client - versions 6.0.3 & 6.0.4) that has been designed with several sections. Each section contains numerous fields. I have used sections in an attempt to logically separate the information being gathered from users.

I’m looking for a way to programmatically open and close specific sections when users create new documents or edit existing documents using this form.

The commands “@Command( [SectionCollapseAll] )” & “@Command( [SectionExpandAll] )” work fine, as well as their LotusScript counterparts, “notesUIDocument.CollapseAllSections” & “notesUIDocument.ExpandAllSections”. But, of course, these collapse and expand all sections on the form.

Is there a way to expand/collapse an individual section programmatically? Using “@Command( [SectionCollapse] )” and “@Command( [SectionExpand] )” would seem to be the logical commands to use, but I don’t see how I can specify a specific section to expand or collapse using these commands.

I have also explored getting to the sections with the following LotusScript classes: NotesDocument > NotesRichTextItem > NotesRichTextNavigator > NotesRichTextSection. However, I have yet to figure out how to get a handle to the sections, since they are part of the form’s design and not part of a rich-text field. (If I am not mistaken, I believe the sections would actually belong to a system “$Body” field on the form. But, is it even possible to access this system field at the document level?)

Thanks in advance for any suggestions.

Subject: This may come too late to be useful to you, but…

… I had a similar kind of requirement, in that I wanted a document to open to a particular section depending on which view it was opened from. For instance I have a complex form with several sections in it and some views show only fields from a particular section, so naturally when the user opens the document from that view they would like to see that section automatically expanded. The way I achieved this was by -(i) putting an anchor (in this case unimaginatively called “my name for the anchor”) inside a particular section, and

(ii) putting this code into the QueryDocumentOpen event of the view…

REM get handle to the document we’re trying to open

Dim docs As NotesDocumentCollection

Dim doc As NotesDocument

Set docs = Source.Documents

Set doc = docs.GetFirstDocument()

Continue = False	'don't let the view open it, as we're going to open it in our own way

REM open the document to the named anchor

Dim uiWS As New NotesUIWorkspace

Dim uiDoc As NotesUIDocument

Set uiDoc = uiWS.EditDocument(False, doc, False, "my name for the anchor")

Thus when the user opens a document in that view the document is opened with the section containing the anchor expanded.

Obviously we can define a different anchor for each section and have a different section automatically expanded depending on which view the document was opened from.

The only snag is that only one section can be automatically expanded by this technique?

I hope someone finds this technique useful?

Mark