Setting Appointment Date/Time fields via COM?

Hello,

Our Calendar Appointment documents have Start/End fields similar to what’s listed at the end of the message.

When I attempt to create an appointment programatically via COM, I’m having a hard time creating a Time/Date data type with just the date or just the time.

The code below creates Time/Date values, but when I look at the properties of the document after it’s saved, the StartDate field has “12:00 AM EST” in it and the StartTime field has “11/30/1999” in it.

l_tDateTimeStart = g_oLNsession.CreateDateTime(“01/19/2010 06:00 PM”)

l_tTimeStart = g_oLNsession.CreateDateTime(“06:00 PM”)

l_tDateStart = g_oLNsession.CreateDateTime(“01/19/2010”)

Doc.ReplaceItemValue(“StartDate”, l_tDateStart.LSLocalTime)

Doc.ReplaceItemValue(“STARTDATETIME”, l_tDateTimeStart.LSLocalTime)

Doc.ReplaceItemValue(“StartTime”, l_tTimeStart.LSLocalTime)

In a v6.5.x template, I could get away with using the “DateOnly” and “TimeOnly” text properties of the datetime object, but with a v8.0.x template I get the following error and the document will not open.


IBM Lotus Notes


Field: ‘tmpStartDate1’: Incorrect data type for operator or @Function: Text expected


OK


Can anyone help?

Thanks.

Bill

=========================

Field Name: StartDate

Data Type: Time/Date

Data Length: 8 bytes

Seq Num: 1

Dup Item ID: 0

Field Flags: SUMMARY

01/19/2010

=========================

Field Name: STARTDATETIME

Data Type: Time/Date

Data Length: 8 bytes

Seq Num: 1

Dup Item ID: 0

Field Flags: SUMMARY

01/19/2010 04:30:00 PM EST

=========================

Field Name: StartTime

Data Type: Time/Date

Data Length: 8 bytes

Seq Num: 1

Dup Item ID: 0

Field Flags: SUMMARY

04:30:00 PM

=========================

Subject: Are the time zone fields on the note?

Hi Bill, Have you set StartTimeZone and EndTimeZone? These can be created using the execute statement on @GetCurrentTimeZone. Their values should look something like this “Z=5$DO=1$DL=3 2 1 11 1 1$ZX=30$ZN=Eastern”

Subject: It was the Start/EndTimeZone fields that were causing the problems.

Turns out the error had to do with the tmpStartDate1 field formula in the Appointment form.

In the formula, it was referring to the StartTimeZone field value, which I was setting incorrectly. Once I corrected that, it doesn’t look like the Appointment form cares how I format all the other Time/Date fields. So, I went back to setting the Time/Date fields to LSLocalTime with the full datetime value and all is well.

I sure wish there was an easy way (i.e. a method call) to assemble the TimeZone string.

Thanks.

Subject: Retrieving the db TimeZone via COM

I was able to find the Lotus Notes TimeZone string value in the CalendarProfile.

In COM, it can be accessed thus:

g_oProfileDoc = g_oLNdb.GetProfileDocument(“CalendarProfile”)

l_aItemTimeZone = g_oProfileDoc.GetItemValue(“TimeZone”)

g_cDBTimeZone = l_aItemTimeZone[1]

HTH,

Bill

Subject: Not always the most reliable field

For folks who travel that field may not always be correct so its better to leverage the @GetCurrentTimeZone functionality which calculates the time zone based on the user’s OS. I believe you have access to this via COM

Based on your sample code, I would change it to the following

Dim g_cTimeZone as Variant

g_cTimeZone = Evaluate(|@GetCurrentTimeZone|)

g_cDBTimeZone = g_cTimeZone(0)

Subject: Interesting, Evaluate() is only available under COM with late binding…

If I Initialize the session object with early binding, I get this error:

OLE exception error: Exception code c0000005. OLE object may be corrupt

With late binding, the method works as expected. Thanks for the tip!

Now I’m wondering what kind of performance benefit early binding really has, and whether or not I can open two NoteSession objects, one with early binding and the othe with late binding…

Hmm…

Bill

Subject: Two sessions can be open at the same time…

But, any documents have to be accessed and referenced from within the session they were created.

IMO, I don’t feel it’s worth managing the code to have two sessions open.

So for my purposes, the real question is “what’s the performance difference between early and late session binding?”

Thanks again for the tip, you’ve exposed me to a very powerful feature available in COM.

Bill