Problem solve Get help with specific problems with your technologies, process and projects.

Compose Document with Default Rich Text - Without Saving the Document

When you open a new document via ComposeDocument, you often want to supply a value for the rich text fields.

If it's just text you want to put in, you can use NotesUIDocument.InsertText.

For anything more complex, you'd want to use the NotesRichTextItem methods to add doclinks, file attachments, etcetera, and have those appear on screen. Unfortunately, Notes doesn't update the front-end rich text from the changes you make in the back end document. Here's how to get around that, without having to save the new document before the user sees it...

1. Create the NotesDocument first, using New or CreateDocument (as opposed to using ComposeDocument and then NotesUIDocument.Document).

2. Set all your fields.

3. If there are rich text fields, call ComputeWithForm.

4. Use the EditDocument method to open the new document. It's never been saved, so the user can quit without saving if they want, and there's no residual document left in the database.

Below is sample code showing this technique being used to create a mail message with a link to the originating database in the body.

Unfortunately, if you're using a mail signature, it gets inserted before the contents you create. But the technique can apply to any form containing a rich text field, not just the memo.

Another way to insert contents into a rich text after the document is already open, is the way Lotus does it with the email signature -- write it to a temporary file in HTML format, then place the cursor where you want it and use the NotesUIDocument.Import method to load it in.


Sub Initialize Dim ses As New notessession Dim db As notesdatabase Dim doc As notesdocument Dim maildb As New notesdatabase("", "") Set db = ses.currentdatabase maildb.openmail Set doc = maildb.createdocument( ) doc.form = "Memo" doc.sendTo = "King@siam.gov" doc.subject = "a new educational tool for your children." Dim body As New notesrichtextitem(doc, "Body") body.appenddoclink db, "" body.appendtext "Click here to see the latest and greatest in English learning online." doc.computewithform False, False Dim ws As New notesuiworkspace, uidoc As notesuidocument Set uidoc = ws.EditDocument( True , doc) End Sub

Dig Deeper on Domino Resources - Part 3

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchContentManagement

Close