I have a bit of code in the querysave event of an existing form that creates a Memo form and sends it to a specific user. The code is as folows:
Dim sess As New NotesSession
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim db As notesdatabase
Dim doc As notesdocument
Dim rtitem As New NotesRichTextItem(doc, "Body")
Set uidoc = ws.CurrentDocument
Set db = sess.currentdatabase
Set doc = db.CreateDocument
Set rtitem = New notesrichtextitem (doc, "Body")
doc.form = "Memo"
doc.Document ID# = uidoc.FieldGetText("DocumentID")
doc.Question = uidoc.FieldGetText("Title")
doc.Modifiedby = uidoc.fieldgettext("currUser")
Call doc.Save(True, True)
Call doc.Send(True, "User Name Here")
However I get the “Must Specify a Parent Document” error message; and when I view the code via the debugger, it hangs at this line:
Set rtitem = New notesrichtextitem (doc, “Body”)
Any help would be greatly appreciated.
Subject: Specify a Parent Document
Dim session As New NotesSession
Dim workspace As New NotesUIWorkspace
Dim db As NotesDatabase
Set db = session.CurrentDatabase
Dim uidoc As NotesUIDocument
Set uidoc = workspace.CurrentDocument
Dim note As NotesDocument
Set note = uidoc.Document
Dim bookmark As NotesDocument
Set bookmark = New NotesDocument( db )
Call bookmark.ReplaceItemValue( "Form", "Bookmark" )
Call bookmark.ReplaceItemValue( "Principal", session.UserName )
Call bookmark.ReplaceItemValue( "Subject", note.GetItemValue( "Title" )(0) )
Call bookmark.ReplaceItemValue( "InheritedSubject", note.GetItemValue( "Title" )(0) )
Call bookmark.ReplaceItemValue( "InheritedDBTitle", db.Title )
Call bookmark.ReplaceItemValue( "FlowStatus", "You can add a message here" )
Dim body As NotesRichTextItem
Set body = New NotesRichTextItem( note, "Body" )
Call body.AppendDocLink( note, "" )
Call body.AddTab( 1 )
Call body.AppendDocLink( db, db.Title )
Call bookmark.ReplaceItemValue( "SendTo", session.UserName )
Call bookmark.ReplaceItemValue( "CopyTo", "" )
Call bookmark.ReplaceItemValue( "BlindCopyTo", "" )
Call bookmark.Send( False )
Subject: Specify a Parent Document
That is because you are declaring the RTItem prior to setting your document
Move this:
Dim rtitem As New NotesRichTextItem(doc, “Body”)
Below this:
Set doc = db.CreateDocument
Or change this:
Dim rtitem As New NotesRichTextItem(doc, “Body”)
to this:
Dim rtitem As NotesRichTextItem
Subject: RE: Specify a Parent Document
That did the trick. Thanks for your help and prompt response Randy.