Your Development & Design Resource
LotusScript Create and Edit NotesDocument via NotesUIWorkspace
03/01/2010 10:18 AM by Chris Toohey
I had a request from a customer recently: they wanted to be able to quick-post a new document in a particular application by highlighting/selecting an existing NotesDocument and pre-populating a Form with values from the highlighted/selected document. Easy enough, but I thought that I would share the technique as part of the things you should know series...
Let's take a look at the function, and then discuss exactly what I'm doing:
Function quickpost(doc As NotesDocument) As NotesDocument Dim s As New NotesSession Dim w As New NotesUIWorkspace Set quickpost = s.CurrentDatabase.CreateDocument Call doc.CopyAllItems(quickpost) 'Remove any NotesItems that you won't need... Call quickpost.RemoveItem("$UpdatedBy") Call quickpost.RemoveItem("$Revisions") 'Add any NotesItems that you will need... Call quickpost.ReplaceItemValue("quickpost", "1") 'Open the newly-created quickpost in the Notes UI... Call w.EditDocument(True, quickpost) End Function
provided by Julian Robichaux at nsftools.com.
... and that's it really: I simply create a new NotesDocument in the target
NotesDatabase (which happens to be the same NotesDatabase in this example),
CopyAllItems from the
doc source NotesDocument to the
quickpost NotesDocument, and then open that newly created
NotesDocument via the NotesUIWorkspace
Using this technique, you don't have to save the
NotesDocument before you open it in the UI, which allows the user to cancel out
of the operation without creating orphan NotesDocuments in your
Of course, you could evolve this markup to include a Data Model
Controller that could conditionally preset the
NotesItems (such as an incremetal revision counter), etc., but that's
a different post for another day!
If you didn't know about this technique, have at it! If you did, let me know what other gems we should be discussing here for the more novice developers (or at least novice Lotus Notes Client developers).