Manage Learn to apply best practices and optimize your operations.

How To Display On The Screen Updates To A Rich Text Item Added Via Lotusscript

When a rich text item is updated in the current document using LotusScript, the
changes are not immediately visible on the screen. In order to see the rich
text that has been added, a user must first save the document via script, quit
out of the document and then reopen it. Is it possible to automate this
process using Script?

Refer to the appropriate section below.

Section 1: Notes 4.1x and Notes 4.0

In Notes 4.1x and 4.0, you must first open a database view that contains the
current document, select the current document within the view, and then use the
NotesUIWorkspace.EditDocument method to reopen the document. The sample script
below illustrates one way to automate this process. The script works as

1. Creates (in the current document) a new Rich Text field named "RT."
2. Attaches the specified file to this Rich Text field.
3. Stores the current document's "Subject" in the "SearchDoc" variable.
4. Sets (through back end classes) the "Form" field and then saves the document.
5. Gets a handle to the view called "Main" and refreshes the view's index
through both the front end and back end classes, so the new document will
display in the view.
6. Sets "SaveOptions" in the current document to "0" (so the user will not be
asked to save the document) and then closes the document.
7. Using the OpenDatabase method, opens the "Main" view (which is categorized
by "Subject") and highlights the appropriate document (based on the "Subject").
8. This document is then reopened using the EditDocument method, and
"SaveOptions" is set back to "1".

Sample Script:

Sub Click(Source As Button)

Dim w As New notesuiworkspace
Dim s As New NotesSession
Dim db As notesdatabase
Dim uidoc As notesuidocument
Dim view As notesview
Dim object As notesembeddedobject
Dim doc As notesdocument
Dim col As NotesDocumentCollection
Dim searchdoc As String
Dim DT As New NotesDateTime("1/1/50")
Set db = s.currentdatabase
Set uidoc = w.currentdocument
Dim rtitem As Variant
Set doc = uidoc.Document

'Create New RichTextItem in the current document
Set rtitem = New NotesRichTextItem(doc,"RT")

'Attach the bitmap
Set object = rtitem.EmbedObject ( EMBED_ATTACHMENT, "",
"c:\temp\access.txt", "Att" )

'Get the key value from the current document
searchdoc = doc.subject(0)

'Set the form field and save document through backend
Doc.Form = "Add Rich Text through UI"

'Refresh the main view through back end and front end methods
Set view = db.getview("Main")
Call view.Refresh
Call w.viewrefresh

'Set save options to zero so that user does not get prompted to save after
closing uidoc
doc.saveoptions = "0"
Call uidoc.close

'Open database to main view, find the document again based on searchdoc and
open it up
Call w.OpenDatabase("","","Main",searchdoc,False,True)
Set uidoc = w.Editdocument(True)

'Reset doc and set saveoptions back to "1"
Set doc = uidoc.document
doc.saveoptions = "1"

End Sub

Section II: Notes 5.x, 4.6x and 4.5x

In Notes 4.5 and above, two optional parameters are available via the
NotesUIWorkspace.EditDocument method. In addition to the Edit/Read mode
parameter, you can also provide a back-end NotesDocument object and a Boolean
value indicating - whether the document should be opened on a read-only basis.
The syntax for the EditDocument method is as follows:

Set notesUIDocument = notesUIWorkspace.EditDocument( [editMode [, notesDocument
[, notesDocumentReadOnly]]] )

The example above may be rewritten as follows to take advantage of the
additional EditDocument parameters (and thereby avoid opening extraneous view

Sub Click(Source As Button)

Dim w As New notesuiworkspace
Dim s As N

Dig Deeper on Domino Resources



  • Favorite iSeries cheat sheets

    Here you'll find a collection of valuable cheat sheets gathered from across the iSeries/ community. These cheat ...

  • HTML cheat sheet

    This is a really cool cheat sheet if you're looking to learn more about HTML. You'll find just about everything you every wanted ...

  • Carol Woodbury: Security

    Carol Woodbury