dominoGuru.com

Your Development & Design Resource

LotusScript Create and Edit NotesDocument via NotesUIWorkspace

dominoGuru.com - it gives me 
wings! 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
This LotusScript was converted to HTML using the ls2html routine,
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 target quickpost NotesDocument, and then open that newly created NotesDocument via the NotesUIWorkspace EditDocument function.

Using this technique, you don't have to save the quickpost NotesDocument before you open it in the UI, which allows the user to cancel out of the operation without creating orphan NotesDocuments in your app!

Of course, you could evolve this markup to include a Data Model Controller that could conditionally preset the quickpost 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).


About the author: Chris Toohey

Thought Leadership, Web & Mobile Application Development, Solutions Integration, Technical Writing & Mentoring

A published developer and webmaster of dominoGuru.com, Chris Toohey specializes in platform application development, solutions integration, and evangelism of platform capabilities and best practices.



More from dominoGuru.com


dominoGuru.com is powered by IBM Notes Domino XPages & hosted by Prominic.NET

Contact Us

Use our Contact / Feedback form or one of these email addresses:

Creative Commons License

Except where otherwise noted, dominoGuru.com by Chris Toohey is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.