Domino Code Fragment

Code Name*
Reloading Rich Text
Date*
04/28/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.18.118.200.136
Description*
A common problem encountered by Notes developers is the limitation of the NotesUIDocument Reload() method. When you open a document and make changes to its back-end version, you can call the Reload method to display the updates in the front-end version. Changes to rich text fields, however, won't show up. As a workaround, you can close and reopen the current document automatically. For example, the following form action button script takes the current document, appends text to its Body field, closes it, then reopens it. This example assumes there is a view named "AllByUNID" which contains all the documents in the database sorted by UNID.
Type*
LotusScript
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
Note that setting uidoc.EditMode to False prevents the user from getting an annoying prompt asking if they want to save changes when no changes were made.
Files/Graphics attachments (if applicable): Code:
Sub Click(Source As Button)
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim rtitem As Variant
Set uidoc = workspace.CurrentDocument
Call uidoc.Save
uidoc.EditMode = False
Set doc = uidoc.Document
Set rtitem = doc.GetFirstItem( "Body" )
Call rtitem.AddNewline(1)
Call rtitem.AppendText( "This text was appended by a form action button script." )
Call doc.Save( True, True )
Call uidoc.Close
Call workspace.OpenDatabase( "", "", "AllByUNID", doc.UniversalID )
Call workspace.EditDocument
End Sub