Prepopulating rich text content for new documents

Since I have finished my last big administration project I am now back into Development for a short wile.

One requirement for an application I am currently building was the ability to prepopulate the content of a rich text field with true rich text content for new documents. ‘True’ rich text content in this context implies that the default value consisted of a number of tables and pre-formated text.

As the default content of the rich text element could be changing and the user want to have the ability to alter it without the need to challenge a Domino Designer (in this case a person doing design changes in Domino applications) I decided to store it in a profile document.

Responsible to move the content from the template to the new document is the Onload event of the form. The advantage of the solution provided below is, that the document itself does not have to be saved at any time. Hence the user can decide at any point in time to just close and cancel the creation of the document.

Please note that the name of the form (FSample) has to be set to the form field of the (in memory) document as the document itself has not been saved at this point of the time but is requested to be re-opened for editing two lines below.

Sub Onload(Source As Notesuidocument)
 Set s = New NotesSession
 Set db = s.CurrentDatabase
 Set uiws = New NotesUIWorkspace
 Set doc = source.Document
 Set docProfile = db.GetProfileDocument ("FProfile")
 If Not doc Is Nothing And Not docProfile Is Nothing Then
  If Not doc.HasItem(sItemName) And docProfile.HasItem (sItemName) Then
  Set rtitem1 = docProfile.GetFirstItem (sItemName)
  Call doc.CopyItem (rtitem1,sItemName)
  Call uiws.EditDocument(True, doc, , , , True)
  Delete source
  End If
 End If
End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *