Your Development & Design Resource
Using the context-sensitive Calendar View RegionDoubleClick event and target Form QueryOpen and PostOpen events to pre-populate NotesDateTime Fields
01/11/2009 09:59 AM by Chris Toohey
As part of the ongoing Public Build: Event Calendar build-off, I find myself want to duplicate a simple feature in the Lots Notes Calendar: double-clicking to create a new Calendar Entry, and using the location on the Calendar View to pre-populate my Event Date and Start Time.
At first, I assumed that this was done via some tricky built-in funcitonality - something like a special NotesItem naming scheme that would allow for that cascaded data from the Event Calendar.
To my surprise, that wasn't the case...
I then went under the assumption that the Calendar View's
RegionDoubleClick had the code that would build the new
NotesDocument in the backend - thus passing my data - and simply
NotesUIWorkspace.EditDocument on my backend
NotesDocument - which would bring that document into edit mode in
the Notes client UI.
Yeah, I was wrong there too!
As it turns out, the
NotesUIWorkspace has a read-only property
CurrentCalendarDateTime. This propery returns "the date
and time of the current (the selected) region in a calendar view", and is
our ticket to pre-populating our new NotesDocument NotesItems.
To start, we simply use Formula to create a new NotesDocument via the
@Command([Compose]) Function, and place said Formula in our
See, the heavy-lifting of this feature is actually performed by the
event Form, specifically by the Form's
Dim dt As NotesDateTime
Now, in the
QueryOpen event of our
Sub Queryopen(Source As Notesuidocument, Mode As Integer, Isnewdoc As Variant,
Continue As Variant)
If (source.IsNewDoc) Then
Dim w As New NotesUIWorkspace
Set dt =New NotesDateTime(w.CurrentCalendarDateTime)
And finally, in the
PostOpen event of our
Sub Postopen(Source As Notesuidocument)
If (source.IsNewDoc) Then
Call source.Document.ReplaceItemValue("date_event", dt.localtime)
Call source.Document.ReplaceItemValue("time_start", dt.localtime)
QueryOpen event, we simply get a handle on the "date
and time of the current (the selected) region in [our] calendar
view" and instantiate them to a variable (
dt in the above
code) in our new NotesDocument. From there, we simply use that variable for the
"pre-population" of our
This can be a pretty simple enhancement to any Lotus Notes client application which uses Calendar-type Views, as it can improve said application's usage by allowing an alternate way to create new content!
And yes, this has been added to our Public Build: Event Calendar application - so for those of you who want a more hands-on demo, expect to see it there!