Calendar Entry

I am trying to create a new calendar entry from one of my applications, and I am able to create the document. The problem is the document only displays in the “All Documents” view and not in the “Calendar” view. The second problem is when the document is opened I receive an error “Invalid or Non Existent Document” and the doc opens fine. If I attempt to save I get the same error.

I have successfully done this with a mail DB that uses the R5 template, but every time I try with a R6 template I get this error.

Below is the code I am using to generate the entry. (R6 Template)

Sub Click(Source As Button)

Dim workspace As New NotesUIWorkspace

Dim item As NotesItem

Dim docmemo As NotesDocument

Dim rtiBody As NotesRichTextItem

Dim db As NotesDatabase

Dim session As NotesSession

Dim uidoc As NotesUIDocument

Dim doc As NotesDocument

Dim itemIcon As NotesItem



Set session = New NotesSession

Set workspace = New NotesUIWorkspace

Set uidoc = workspace.CurrentDocument

Set db = session.CurrentDatabase

Set docMemo = New NotesDocument(db)

Set doc=uidoc.Document



'On Error Goto quitit





Dim requestor As String

requestor = uidoc.FieldGetText("Requestor")

Dim mgr As String

mgr = uidoc.FieldGetText("Manager")

Dim sec As String

sec = uidoc.FieldGetText("Secretary")

Dim purpose As String

purpose = uidoc.FieldGetText("PPose")

Dim opurpose As String

opurpose = uidoc.FieldGetText("OtherPPose")

Dim ppose As String

If purpose = "Other" Then ppose = opurpose Else ppose = purpose

Dim dcity As String

dcity = uidoc.FieldGetText("DCity")

Dim ddate As Variant

ddate = uidoc.FieldGetText("DDate")

Dim rdate As Variant

rdate = uidoc.FieldGetText("RDate")

Dim tdays As String

tdays = uidoc.FieldGetText("TDays")







	'Open the Calendar

Dim dbf As New NotesDatabase("", "")

Call dbf.Open("CITSVAN1", "Calendars//mancalen.nsf")

Dim subj As String

subj = requestor & " in " & dcity & " for " & tdays & " days"

Dim newdoc As NotesDocument

Set newdoc = dbf.CreateDocument

Dim startdttm As NotesDateTime

Dim enddttm As NotesDateTime





If ddate <> "" Then

	newdoc.form = "_Calendar Entry"

	newdoc.From = requestor

	newdoc.Principal = requestor

	newdoc.Chair = requestor

	newdoc.~$BusyName = requestor

	newdoc.~$BusyPriority = "1"

	newdoc.Subject = subj 

	newdoc.Body =subj

	Set startdttm = New NotesDateTime(doc.StartDate(0) & " " & doc.StartTime(0)) 

	Set enddttm = New NotesDateTime(doc.StartDate(0) & " " & doc.EndTime(0)) 

	newdoc.StartDateTime = startdttm.LSLocalTime 

	newdoc.StartDate = ddate

	newdoc.StartDate_2 = ddate

	newdoc.EndDateTime = enddttm.LSLocalTime 

	newdoc.EndDate = rdate

	newdoc.EndDate_2 = rdate

	newdoc.StartTime = startdttm.LSLocalTime

	newdoc.StartTime_2 = startdttm.LSLocalTime

	newdoc.tmpStartTime_local = startdttm.LSLocalTime

	newdoc.EndTime = enddttm.LSLocalTime

	newdoc.EndTime_2 = enddttm.LSLocalTime

	newdoc.DispDur_2 = doc.dspDuration

	newdoc.DispDur_1 = doc.dspDuration 

	newdoc.DispDuration_1 = doc.dspDuration

	newdoc.calendarDateTime = startdttm.LSLocalTime

	newdoc.StartTimeZone = "Z=5$DO=1$DL=4 1 1 10 -1 1$ZX=25$ZN=Eastern"

	newdoc.EndTimeZone = "Z=5$DO=1$DL=4 1 1 10 -1 1$ZX=25$ZN=Eastern" 

	newdoc.~$NoPurge = enddttm.LSLocalTime

	newdoc.tmpWasMailed = "1"

	newdoc.MailOptions=""

	newdoc.ExcludeFromView = "D; S"

	newdoc.OrgTable = "C0"

	newdoc.Location = doc.EvtLocation

	Set itemIcon = New NotesItem(newdoc, "_ViewIcon", 160)

	itemIcon.IsSummary = True

	newdoc.Logo = "stdNotesLtr0"

	newdoc.OrgState = "x"

	newdoc.Repeats = ""

	newdoc.Resources = ""

	newdoc.SaveOptions = ""

	newdoc.SequenceNum = "1"

	Call newdoc.save(True, True)

End If

End Sub

Any suggestions would be appreciated.

Ian

Subject: Calendar Entry

Not that this really helps, but I don’t think you have two problems, I think you have one. I would think that the reason it is not displaying in the calendar view is tied to the fact that somehow the database thinks the doc does not half-way exist - even though it shows up in all docs view.I would think that if you resolve the one problem, it will show up in the calendar view.

Just a hunch that may help focus your efforts toward resolution.

Subject: Calendar Entry

I have made a little more progress, but I am still not there yet. I added a few more fields and now the Invalid or Non Existant Document error no longer comes up, but I get a save error that says field in note has wrong datatype.

Below is the updated code.

Sub Click(Source As Button)

Dim workspace As New NotesUIWorkspace

Dim item As NotesItem

Dim docmemo As NotesDocument

Dim rtiBody As NotesRichTextItem

Dim db As NotesDatabase

Dim session As NotesSession

Dim uidoc As NotesUIDocument

Dim doc As NotesDocument

Dim itemIcon As NotesItem



Set session = New NotesSession

Set workspace = New NotesUIWorkspace

Set uidoc = workspace.CurrentDocument

Set db = session.CurrentDatabase

Set docMemo = New NotesDocument(db)

Set doc=uidoc.Document



'On Error Goto quitit





Dim requestor As String

requestor = uidoc.FieldGetText("Requestor")

Dim mgr As String

mgr = uidoc.FieldGetText("Manager")

Dim sec As String

sec = uidoc.FieldGetText("Secretary")

Dim purpose As String

purpose = uidoc.FieldGetText("PPose")

Dim opurpose As String

opurpose = uidoc.FieldGetText("OtherPPose")

Dim ppose As String

If purpose = "Other" Then ppose = opurpose Else ppose = purpose

Dim dcity As String

dcity = uidoc.FieldGetText("DCity")

Dim ddate As Variant

ddate = uidoc.FieldGetText("DDate")

Dim rdate As Variant

rdate = uidoc.FieldGetText("RDate")

Dim tdays As String

tdays = uidoc.FieldGetText("TDays")

Dim tdaysn As Integer

tdaysn = Cint(tdays)







	'Open the Calendar

Dim dbf As New NotesDatabase("", "")

Call dbf.Open("CITSVAN1", "Calendars//mancalen.nsf")

Dim subj As String

subj = requestor & " in " & dcity & " for " & tdays & " days"

Dim newdoc As NotesDocument

Set newdoc = dbf.CreateDocument

Dim startdttm As NotesDateTime

Dim enddttm As NotesDateTime

Dim uid As String

uid = newdoc.UniversalID



If ddate <> "" Then

	newdoc.form = "_Calendar Entry"

	newdoc.From = requestor

	newdoc.Principal = requestor

	newdoc.Chair = requestor

	newdoc.~$BusyName = requestor

	newdoc.~$BusyPriority = "1"

	newdoc.Subject = subj 

	newdoc.Body =subj

	Set startdttm = New NotesDateTime(doc.StartDate(0) & " " & doc.StartTime(0)) 

	Set enddttm = New NotesDateTime(doc.StartDate(0) & " " & doc.EndTime(0)) 

	newdoc.~$REF = uid

	newdoc.tmpAction = "2"

	newdoc.~$RefOptions = "1"

	newdoc.BookFreeTime = "0"

	newdoc.CopyTo = ""

	newdoc.DocAuthors = session.UserName

	newdoc.Duration = tdaysn

	newdoc.~$NoPurge = enddttm.LSLocalTime 

	newdoc.StartDateTime = startdttm.LSLocalTime 

	newdoc.StartDate = ddate

	newdoc.StartDate_2 = ddate

	newdoc.EndDateTime = enddttm.LSLocalTime 

	newdoc.EndDate = rdate

	newdoc.EndDate_2 = rdate

	newdoc.StartTime = startdttm.LSLocalTime

	newdoc.StartTime_2 = startdttm.LSLocalTime

	newdoc.tmpStartTime_local = startdttm.LSLocalTime

	newdoc.EndTime = enddttm.LSLocalTime

	newdoc.EndTime_2 = enddttm.LSLocalTime

	newdoc.DispDur_2 = doc.dspDuration

	newdoc.DispDur_1 = doc.dspDuration 

	newdoc.DispDuration_1 = doc.dspDuration

	newdoc.calendarDateTime = startdttm.LSLocalTime

	newdoc.StartTimeZone = "Z=5$DO=1$DL=4 1 1 10 -1 1$ZX=25$ZN=Eastern"

	newdoc.EndTimeZone = "Z=5$DO=1$DL=4 1 1 10 -1 1$ZX=25$ZN=Eastern" 

	newdoc.~$NoPurge = enddttm.LSLocalTime

	newdoc.tmpWasMailed = "1"

	newdoc.MailOptions=""

	newdoc.ExcludeFromView = "D; S"

	newdoc.OrgTable = "C0"

	newdoc.Location = doc.EvtLocation

	Set itemIcon = New NotesItem(newdoc, "_ViewIcon", 160)

	itemIcon.IsSummary = True

	newdoc.Logo = "stdNotesLtr0"

	newdoc.OrgState = "x"

	newdoc.Repeats = ""

	newdoc.Resources = ""

	newdoc.SaveOptions = ""

	newdoc.SequenceNum = "1"

	Call newdoc.save(True, True)

End If

End Sub

Thanks,

Ian

Subject: RE: Calendar Entry

I finally worked this out. There are a lot of fields that are required, but the keys are the Start Date, End Date and calendardatetime. The CalendarDateTime field is pretty tricky, but I worked it out.

Below is the working code…

Sub Click(Source As Button)

On Error Resume Next

Dim workspace As New NotesUIWorkspace

Dim item As NotesItem

Dim docmemo As NotesDocument

Dim rtiBody As NotesRichTextItem

Dim db As NotesDatabase

Dim session As NotesSession

Dim uidoc As NotesUIDocument

Dim doc As NotesDocument

Dim itemIcon As NotesItem



Set session = New NotesSession

Set workspace = New NotesUIWorkspace

Set uidoc = workspace.CurrentDocument

Set db = session.CurrentDatabase

Set docMemo = New NotesDocument(db)

Set doc=uidoc.Document





Dim requestor As String

requestor = uidoc.FieldGetText("Requestor")

Dim mgr As String

mgr = uidoc.FieldGetText("Manager")

Dim sec As String

sec = uidoc.FieldGetText("Secretary")

Dim purpose As String

purpose = uidoc.FieldGetText("PPose")

Dim opurpose As String

opurpose = uidoc.FieldGetText("OtherPPose")

Dim ppose As String

If purpose = "Other" Then ppose = opurpose Else ppose = purpose

Dim dcity As String

dcity = uidoc.FieldGetText("DCity")

Dim ddate As Variant

ddate = uidoc.FieldGetText("DDate")

Dim rdate As Variant

rdate = uidoc.FieldGetText("RDate")

Dim tdays As String

tdays = uidoc.FieldGetText("TDays")

Dim tdaysn As Integer

tdaysn = Cint(tdays)

Dim d2 As Variant

d2 = uidoc.FieldGetText("Day2")

Dim d3 As Variant

d3 = uidoc.FieldGetText("Day3")

Dim d4 As Variant

d4 = uidoc.FieldGetText("Day4")

Dim d5 As Variant

d5 = uidoc.FieldGetText("Day5")

Dim d6 As Variant

d6 = uidoc.FieldGetText("Day6")

Dim d7 As Variant

d7 = uidoc.FieldGetText("Day7")

Dim d8 As Variant

d8 = uidoc.FieldGetText("Day8")

Dim d9 As Variant

d9 = uidoc.FieldGetText("Day9")

Dim d10 As Variant

d10 = uidoc.FieldGetText("Day10")

Dim d11 As Variant

d11 = uidoc.FieldGetText("Day11")

Dim d12 As Variant

d12 = uidoc.FieldGetText("Day12")

Dim d13 As Variant

d13 = uidoc.FieldGetText("Day13")

Dim d14 As Variant

d14 = uidoc.FieldGetText("Day14")

'Open the Calendar

Dim dbf As New NotesDatabase("", "")

Call dbf.Open("CITSVAN1", "Calendars//mancalen.nsf")

Dim subj As String

subj = requestor & " in " & dcity & " for " & tdays & " days"

Dim newdoc As NotesDocument

Set newdoc = dbf.CreateDocument

Dim startdttm As NotesDateTime

Dim enddttm As NotesDateTime

Dim uid As String

uid = newdoc.UniversalID



If ddate <> "" Then

	newdoc.form = "_Calendar Entry"

	newdoc.From = "CN=Canon ITS Management/OU=VA/O=CITS"

	newdoc.Principal = "CN=Canon ITS Management/OU=VA/O=CITS"

	newdoc.~$AltPrincipal = "CN=Canon ITS Management/OU=VA/O=CITS"

	newdoc.Chair = "CN=Canon ITS Management/OU=VA/O=CITS"

	newdoc.AltChair = "CN=Canon ITS Management/OU=VA/O=CITS"

	newdoc.~$BusyName = "CN=Canon ITS Management/OU=VA/O=CITS"

	newdoc.~$BusyPriority = "1"

	newdoc.Subject = subj 

	newdoc.Body =subj

	newdoc.AppointmentType = "2"

	Set startdttm = New NotesDateTime(ddate & " " & doc.StartTime(0)) 

	Set enddttm = New NotesDateTime(rdate & " " & doc.EndTime(0)) 

	Dim caldattime (0 To 14) As Variant

	caldattime(0) = Cdat(startdttm.LSLocalTime)

	caldattime(1) = Cdat(d2)

	caldattime(2) = Cdat(d3)

	caldattime(3) = Cdat(d4)

	caldattime(4) = Cdat(d5)

	caldattime(5) = Cdat(d6)

	caldattime(6) = Cdat(d7)

	caldattime(7) = Cdat(d8)

	caldattime(8) = Cdat(d9)

	caldattime(9) = Cdat(d10)

	caldattime(10) = Cdat(d11)

	caldattime(11) = Cdat(d12)

	caldattime(12) = Cdat(d13)

	caldattime(13) = Cdat(d14)

	caldattime(14) = Cdat(enddttm.LSLocalTime)

	

	newdoc.ReplaceItemValue "CalendarDateTime", caldattime

	newdoc.~$REF = uid

	newdoc.DocAuthors = session.UserName

	newdoc.Duration = tdaysn

	newdoc.~$NoPurge = enddttm.LSLocalTime 

	newdoc.StartDateTime = startdttm.LSLocalTime 

	newdoc.StartDate = ddate

	newdoc.EndDateTime = enddttm.LSLocalTime 

	newdoc.EndDate = rdate

	newdoc.StartTime = startdttm.LSLocalTime

	newdoc.EndTime = enddttm.LSLocalTime

	newdoc.ExcludeFromView = "D; S"

	Set itemIcon = New NotesItem(newdoc, "_ViewIcon", 160)

	itemIcon.IsSummary = True

	newdoc.OrgState = "x"

	newdoc.tmpOwnerHW = 0

	Call newdoc.ComputeWithForm(True, False)

	Call newdoc.save(True, True)

End If

End Sub

Hopefuly this will help someone in the future.

Ian

Subject: Calendar Entry

I have all the errors taken care of, but for some reason the document does not show up in the calendar view.

Sub Click(Source As Button)

Dim workspace As New NotesUIWorkspace

Dim item As NotesItem

Dim docmemo As NotesDocument

Dim rtiBody As NotesRichTextItem

Dim db As NotesDatabase

Dim session As NotesSession

Dim uidoc As NotesUIDocument

Dim doc As NotesDocument

Dim itemIcon As NotesItem



Set session = New NotesSession

Set workspace = New NotesUIWorkspace

Set uidoc = workspace.CurrentDocument

Set db = session.CurrentDatabase

Set docMemo = New NotesDocument(db)

Set doc=uidoc.Document





Dim requestor As String

requestor = uidoc.FieldGetText("Requestor")

Dim mgr As String

mgr = uidoc.FieldGetText("Manager")

Dim sec As String

sec = uidoc.FieldGetText("Secretary")

Dim purpose As String

purpose = uidoc.FieldGetText("PPose")

Dim opurpose As String

opurpose = uidoc.FieldGetText("OtherPPose")

Dim ppose As String

If purpose = "Other" Then ppose = opurpose Else ppose = purpose

Dim dcity As String

dcity = uidoc.FieldGetText("DCity")

Dim ddate As Variant

ddate = uidoc.FieldGetText("DDate")

Dim rdate As Variant

rdate = uidoc.FieldGetText("RDate")

Dim tdays As String

tdays = uidoc.FieldGetText("TDays")

Dim tdaysn As Integer

tdaysn = Cint(tdays)

'Open the Calendar

Dim dbf As New NotesDatabase("", "")

Call dbf.Open("CITSVAN1", "Calendars//mancalen.nsf")

Dim subj As String

subj = requestor & " in " & dcity & " for " & tdays & " days"

Dim newdoc As NotesDocument

Set newdoc = dbf.CreateDocument

Dim startdttm As NotesDateTime

Dim enddttm As NotesDateTime

Dim uid As String

uid = newdoc.UniversalID



If ddate <> "" Then

	newdoc.form = "_Calendar Entry"

	newdoc.From = "CN=Canon ITS Management/OU=VA/O=CITS"

	newdoc.Principal = "CN=Canon ITS Management/OU=VA/O=CITS"

	newdoc.Chair = "CN=Canon ITS Management/OU=VA/O=CITS"

	newdoc.~$BusyName = "CN=Canon ITS Management/OU=VA/O=CITS"

	newdoc.~$BusyPriority = "1"

	newdoc.Subject = subj 

	newdoc.Body =subj

	newdoc.AppointmentType = "2"

	newdoc.CalendarDateTime = ddate

	Set startdttm = New NotesDateTime(doc.StartDate(0) & " " & doc.StartTime(0)) 

	Set enddttm = New NotesDateTime(doc.StartDate(0) & " " & doc.EndTime(0)) 

	newdoc.~$REF = uid

	newdoc.tmpAction = "2"

	newdoc.~$RefOptions = "1"

	newdoc.BookFreeTime = "0"

	newdoc.CopyTo = ""

	newdoc.DocAuthors = session.UserName

	newdoc.Duration = tdaysn

	newdoc.~$NoPurge = enddttm.LSLocalTime 

	newdoc.StartDateTime = startdttm.LSLocalTime 

	newdoc.StartDate = ddate

	newdoc.StartDate_2 = ddate

	newdoc.EndDateTime = enddttm.LSLocalTime 

	newdoc.EndDate = rdate

	newdoc.EndDate_2 = rdate

	newdoc.StartTime = startdttm.LSLocalTime

	newdoc.StartTime_2 = startdttm.LSLocalTime

	newdoc.tmpStartTime_local = startdttm.LSLocalTime

	newdoc.EndTime = enddttm.LSLocalTime

	newdoc.EndTime_2 = enddttm.LSLocalTime

	newdoc.DispDur_2 = doc.dspDuration

	newdoc.DispDur_1 = doc.dspDuration 

	newdoc.DispDuration_1 = doc.dspDuration

	newdoc.calendarDateTime = startdttm.LSLocalTime

	newdoc.StartTimeZone = "Z=5$DO=1$DL=4 1 1 10 -1 1$ZX=25$ZN=Eastern"

	newdoc.EndTimeZone = "Z=5$DO=1$DL=4 1 1 10 -1 1$ZX=25$ZN=Eastern" 

	newdoc.~$NoPurge = enddttm.LSLocalTime

	newdoc.tmpWasMailed = "1"

	newdoc.MailOptions=""

	newdoc.ExcludeFromView = "D; S"

	newdoc.OrgTable = "C0"

	newdoc.Location = doc.EvtLocation

	Set itemIcon = New NotesItem(newdoc, "_ViewIcon", 160)

	itemIcon.IsSummary = True

	newdoc.Logo = "stdNotesLtr0"

	newdoc.OrgState = "x"

	newdoc.Repeats = ""

	newdoc.Resources = ""

	newdoc.SaveOptions = ""

	newdoc.SequenceNum = "1"

	newdoc.AppendEndTime = "8:00:00 PM"

	newdoc.AppendStartTime = "12:00:00 AM"

	newdoc.MeetingType = "1"

	Call newdoc.save(True, True)

End If

End Sub

Any ideas?

Thanks in advance.

Ian