Hi,
I am trying to add entry in my calendar from my application form when i click the button “Add to Calendar”. It getting populating to the caledar when i see from Debug. But after wards refreshes and StartDate and EndDate goes from the caledar but rest of the things are coming properly.
Pls help.
Here is my code…
===========================
Dim session As New NotesSession
Dim db As New NotesDatabase ("","")
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim userName As New notesname(session.username)
Dim dbfilename As String
Dim dbserver As String
Dim value As Integer
Dim currdoc As NotesDocument
Call db.OpenMail
dbfilename=db.filepath
dbserver = db.server
value = Messagebox ("Do you want this to be " + Chr(10) + "added to your calendar?", (4+32+0+0), "Add To Calendar")
temp = Evaluate("@MailDbName") ' open the current mail database
Dim caldb As New NotesDatabase(temp(0),temp(1))
Set uidoc=ws.CurrentDocument
Set currdoc=uidoc.Document
If (value = 6) Then
Set uidoc = ws.ComposeDocument (caldb.Server,caldb.FilePath,"Appointment")
Dim cal As NotesDocument
Set cal=uidoc.Document
cal.Subject=currdoc.MeetingSubject(0)
cal.StartDate=currdoc.StartDt(0)
cal.EndDate=currdoc.EndDt(0)
cal.EnterSendTo=currdoc.ChairPerson(0)
cal.Categories=currdoc.Category(0)
cal.Location=currdoc.MeetingPlace(0)
Call cal.Save(True,False)
Messagebox ("Details have been updated to Caledar")
Else
Messagebox ("Calendar not changed.")
End If
=============================================
Subject: What’s wrong in this code?
I wonder if it has something to do with the mixture of front and backend methods you are using on the cal document.
Have you tried doing everything through the backend i.e.
replacing
Set uidoc = ws.ComposeDocument (caldb.Server,caldb.FilePath,“Appointment”)
Dim cal As NotesDocument
Set cal=uidoc.Document
with
Set cal = caldb.CreateDocument
cal.form=“Appointment”
HTH - Rufus.
Subject: RE: What’s wrong in this code?
ya, I have tried that also…but no success
Subject: RE: What’s wrong in this code?
Just had a closer look at your code, and I am not convinced you are populating the right fields.
If you create a calendar entry manually, and look at the document properties for the fields, then you’ll notice a lot more than you are creating. The calendar view(s) use the StartDateTime, EndDateTime and CalendarDateTime fields, with StartDate / EndDate being there purely to allow users to enter a meaningful date!
I suggest creating the document through the backend, and instead of setting StartDate / EndDate set StartDateTime and EndDateTime.
You’ll also need CalendarDateTime and AppointmentType set for it to appear correctly in the view.
HTH - Rufus.
Subject: RE: What’s wrong in this code?
Here is the code I used to populate a calendar from the back end. The values I am using are being pulled from the uidoc that the user is working with.
Dim newdocp As NotesDocument
Dim itemIcon As NotesItem
Dim tdaysn As Integer
tdaysn = Cint(tdays2)
Set newdocp = db.CreateDocument
Dim startdttm As NoteSDateTime
Dim enddttm As NoteSDateTime
Dim uid As String
uid = newdocp.UniversalID
If SDate <> "" Then
newdocp.form = "_Calendar Entry"
newdocp.From = "CN=" & requestor & "/OU=VA/O=CITS"
newdocp.Principal = "CN=" & requestor & "/OU=VA/O=CITS"
newdocp.~$AltPrincipal ="CN=" & requestor & "/OU=VA/O=CITS"
newdocp.Chair = "CN=" & requestor & "/OU=VA/O=CITS"
newdocp.AltChair = "CN=" & requestor & "/OU=VA/O=CITS"
newdocp.~$BusyName = "CN=" & requestor & "/OU=VA/O=CITS"
newdocp.~$BusyPriority = "1"
newdocp.Subject = subj
newdocp.Body =subj
newdocp.AppointmentType = "2"
Set startdttm = New NoteSDateTime(sdate2 & " " & doc.StartTime(0))
Set enddttm = New NoteSDateTime(edate2 & " " & doc.EndTime(0))
newdocp.~$REF = uid
newdocp.DocAuthors = s.UserName
newdocp.Duration = tdaysn
newdocp.~$NoPurge = enddttm.LSLocalTime
newdocp.StartDateTime = startdttm.LSLocalTime
newdocp.StartDate = sdate3
newdocp.EndDateTime = enddttm.LSLocalTime
newdocp.EndDate = edate3
newdocp.StartTime = startdttm.LSLocalTime
newdocp.EndTime = enddttm.LSLocalTime
newdocp.ExcludeFromView = "D; S"
Set itemIcon = New NotesItem(newdocp, "_ViewIcon", 160)
itemIcon.IsSummary = True
newdocp.OrgState = "x"
newdocp.tmpOwnerHW = 0
Dim caldattime (0 To 20) As Variant
caldattime(0) = Cdat(startdttm.LSLocalTime)
caldattime(1) = Cdat(dd2)
caldattime(2) = Cdat(dd3)
caldattime(3) = Cdat(dd4)
caldattime(4) = Cdat(dd5)
caldattime(5) = Cdat(dd6)
caldattime(6) = Cdat(dd7)
caldattime(7) = Cdat(dd8)
caldattime(8) = Cdat(dd9)
caldattime(9) = Cdat(dd10)
caldattime(10) = Cdat(dd11)
caldattime(11) = Cdat(dd12)
caldattime(12) = Cdat(dd13)
caldattime(13) = Cdat(dd14)
caldattime(14) = Cdat(dd15)
caldattime(15) = Cdat(dd16)
caldattime(16) = Cdat(dd17)
caldattime(17) = Cdat(dd18)
caldattime(18) = Cdat(dd19)
caldattime(19) = Cdat(dd20)
caldattime(20) = Cdat(enddttm.LSLocalTime)
newdocp.ReplaceItemValue "CalendarDateTime", caldattime
Call newdocp.ComputeWithForm(True, False)
Call newdocp.save(True, True)
End If
The caldattime is an array that populates all the days you want the entry to span. So if you want an entry to appear for 5/5/05 - 5/10/05 you need each of these days to be in that field.
I hope this helps you. I battled with this for a long time.
Ian
Subject: RE: What’s wrong in this code?
I am experiencing same problem.A code as simple as below , does not run on server.
Is there any issue related to Domino 6?
Sub Initialize
On Error Goto errorPara
Dim aVarDat As Variant
aVarDat = Cdat("10-10-2004")
Exit Sub
errorPara:
Print "Error" & Err & Error$ & | at line | & Cstr (Erl)
End Sub
Subject: What’s wrong in this code?
HiCode is fine.,Is this like that the values(StartDt and CloseDt) are not populating in the calendar only or else in the created document also the values for StartDt and CloseDt are not populating.If the values are there in the document., then may be i hope that it will be a problem with columns in the calander.
Subject: What’s wrong in this code?
Hi Sanjay,
before answering your query, just a suggestion to you… try to search for a similar topic before posting.
anyways here’s the answer
http://www-10.lotus.com/ldd/nd6forum.nsf/ShowMyTopicsAllFlatweb/e9d6453fbed8503b85256ff8002704b1?OpenDocument
-Shiva.