Calendar Application Notifications

Mindwatering Incorporated

Author: Tripp W Black

Created: 01/25/2005 at 06:12 PM

 

Category:
Notes Developer Tips
LotusScript

This code was originally posted in either the R5 or Domino 6 forums on Notes.net.
You should be able to get to the discussion thread by searching the forum.

Posted by Michael B Hughes on 10.Jan.05 at 03:24 PM using a Web browser
Category: Notes ClientRelease: 6.5Platform: All Platforms

Here's an agent used in a Vacation Request db that will update the Managers calendar of the individual submitting the Vacation Request.

You will have to modify field names and what mail files get updated, but hopefully this will get you started.

Dim s As New NotesSession
Dim db As NotesDatabase
Dim maildb As NotesDatabase
Dim nabdb As NotesDatabase
Dim v As NotesView
Dim v2 As NotesView
Dim v3 As NotesView
Dim entry As NotesViewEntry
Dim doc As NotesDocument
Dim vdoc As NotesDocument
Dim caldoc As NotesDocument
'*****get CalendarDateTime set to 8 AM instead of 12 AM
Dim dateTime As NotesDateTime
Dim dateTime2 As NotesDateTime

'*****Set all variables in attempt to see why getting error
Dim vactype As String
Dim key As String
Dim vhours As String
Dim sername As String
Dim filename As String
Dim key2 As String
Dim sername2 As String
Dim filename2 As String



Set db = s.CurrentDatabase
Set v = db.GetView("(calendarupdate)")
v.AutoUpdate = False
Set doc = v.GetFirstDocument


Do While Not (doc Is Nothing)
'*****Set variables
vactype = doc.daytype(0)
key = doc.dayname(0)
vhours = doc.vachours(0)

'*****get the user's mail file
sername = db.Server
Set nabdb = s.GetDatabase(sername, "names.nsf")
Set v2 = nabdb.GetView("($mailfile)")
Set entry = v2.GetEntryByKey(key)

'****if entry no longer with company
If Not entry Is Nothing Then
filename = entry.ColumnValues(1)

'*****Open the user's mail file and add entry
Set maildb = s.GetDatabase(sername, filename)
Set caldoc = maildb.CreateDocument
caldoc.Form = "Appointment"
caldoc.Subject = vactype + " Day"+ " " + vhours + " Hours"
caldoc.AppointmentType = "2"
caldoc.StartDate = doc.vacdate(0)
caldoc.EndDate = doc.vacdate(0)
caldoc.StartTime = "08:00:00 AM"
caldoc.EndTime = "05:00:00 PM"
Dim Item As NotesItem
Set item = caldoc.ReplaceItemValue("_ViewIcon", 9)
Dim mItem As NotesItem
Set mitem = caldoc.ReplaceItemValue("$MessageType","Not a Draft")

'*****change entry to Public
Dim pItem As NotesItem
Set pitem = caldoc.ReplaceItemValue("$PublicAccess","1")

Set dateTime = New NotesDateTime(doc.vacdate(0) + " " + "08:00 AM")
'caldoc.CalendarDateTime = doc.vacdate(0) '+ " " + "08:00:00 AM"
Set CDT = caldoc.ReplaceItemValue("CalendarDateTime", dateTime)
Call caldoc.Save(True,True)

'*****Get the manager's mail file
If doc.realmgrname(0) = "Manager Name" Then
key2 = "Use This Name"
Else
key2 = doc.realmgrname(0)
End If
sername2 = db.Server
Set nabdb = s.GetDatabase(sername2, "names.nsf")
Set v3 = nabdb.GetView("($mailfile)")
Set entry = v3.GetEntryByKey(key2)
filename2 = entry.ColumnValues(1)

'*****Open the manager's mail file and add entry
Set maildb = s.GetDatabase(sername2, filename2)
Set caldoc = maildb.CreateDocument
caldoc.Form = "Appointment"
caldoc.Subject = key + " " + vactype + " Day" + " " + vhours + " Hours"
caldoc.AppointmentType = "4"
caldoc.StartDate = doc.vacdate(0)
caldoc.EndDate = doc.vacdate(0)
caldoc.StartTime = "08:00:00 AM"
caldoc.EndTime = "05:00:00 PM"
Dim Item2 As NotesItem
Set item2 = caldoc.ReplaceItemValue("_ViewIcon", 10)
Dim mItem2 As NotesItem
Set mitem2 = caldoc.ReplaceItemValue("$MessageType","Not a Draft")

'*****change entry to Public
Dim pItem2 As NotesItem
Set pitem2 = caldoc.ReplaceItemValue("$PublicAccess","1")

Set dateTime2 = New NotesDateTime(doc.vacdate(0) + " " + "08:00 AM")
'caldoc.CalendarDateTime = doc.vacdate(0) '+ " " + "08:00:00 AM"
Set CDT = caldoc.ReplaceItemValue("CalendarDateTime", dateTime2)
Call caldoc.Save(True,True)

'*****set the original doc so it disappears from the view
doc.agent = "1"
Call doc.Save(True, True)
End If
Set doc = v.GetNextDocument(doc)
Loop

previous page