dominoGuru.com

Your Development & Design Resource

Using the context-sensitive Calendar View RegionDoubleClick event and target Form QueryOpen and PostOpen events to pre-populate NotesDateTime Fields

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 call a 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 named 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 Calendar View's RegionDoubleClick event.

Using the Calendar View RegionDoubleEvent to create a new NotesDocument 
with Formula

See, the heavy-lifting of this feature is actually performed by the event Form, specifically by the Form's QueryOpen and PostOpen events.

First, our event Form's Declarations:

Dim dt As NotesDateTime

Now, in the QueryOpen event of our event Form:

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)
 End If

End Sub

And finally, in the PostOpen event of our event Form:

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)
 End If

End Sub

In the 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 date_event and time_start NotesItems.

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!


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.