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