Mental block working with NotesDateTime objects

This has always plagued me…I wish I could find a good tutorial that would let me practice all of the little nuances when working with NotesDateTime objects in script.

OK…here is what is happening here:

I have a PostSave event that is calling a function with arguments. The arguments are NotesDateTime objects. In the called function, I am creating a document, then trying to put the NotesDateTime values on the new document.

Example(only relevant code here):

from PostSave…

Call Invite(cdt as NotesDateTime, sdt as NotesDateTime, edt as NotesDateTime)

Now, in the Invite function, I have this:

Function Invite(cdt As NotesDateTime, sdt As NotesDateTime, edt As NotesDateTime, sd As NotesDateTime)As String

…set db object…

Set InviteEmail = New NotesDocument(db)

InviteEmail.CalendarDateTime = cdt

…here I get type mismatch error. I tested with a msgbox of TypeName(cdt), etc, and they are showing up here as NotesDateTime objects (I cannot get debug to work here, of course)

Can anyone shed some light on what I a doing wrong? I bet it has something to do with how the objects are instantiated, or whatever.

Thanks in advance.

  • Matt

Subject: Mental block working with NotesDateTime objects

Matt, I think what you need is:InviteEmail.CalendarDateTime = cdt.LSLocalTime

since the property LSLocalTime returns a LotusScript variant which you can use to directly populate the item on your document.

Subject: Thanks…that was it!

Nigel,

Thanks for your help. I have so much to learn about the proper way to handle the NotesDateTime class. Lots of little tricks.

Thanks again.

Subject: Mental block working with NotesDateTime objects

If this is what you have:

Set InviteEmail = New NotesDocument(db)

InviteEmail.CalendarDateTime = cdt

Then .CalendarDateTime does not exist as an item yet. Create it as an item, something like this:

Dim itemCalenderDateTime As NotesItem

Set itemCalenderDateTime = New NotesItem( InviteEmail, “CalendarDateTime”, cdt)