Notes Ninjas Notes Ninjas
Lotus Notes hints, tips, error messages
Add days off to Lotus Notes calendar

Hint Short Cut: Add this to your code & documentation to help you find this page.
http://www.notesninjas.com/#AddToCalendar or http://www.notesninjas.com/A555F9/nn.nsf/ByAlias/AddToCalendar


The trick with this is to call the computewithform...





 

 

Code:

Stick this in an action button on the form.

Uses fields requester, datefrom and dateto and status from current document.

 

'Code to add a busy day to user's notes calendar.

 ' See http://www.notesninjas.com/#AddToCalendar for latest version

On Error Goto errhdlr
Dim uiw As New NotesUIWorkspace
Dim uidoc As notesuidocument
Set uidoc=uiw.currentdocument
If uidoc.IsNewDoc Then
 Messagebox "This is a new document, please save it first."
 End
End If
Dim doc As notesdocument
Set doc = uidoc.document
Dim s As New notessession
Call s.SetEnvironmentVar("CSDocType","2")

Dim maildb As notesdatabase
Dim mdb As Variant
mdb=Evaluate("@maildbname")
Print "maildb:" & mdb(0) & "-" & mdb(1)
Set maildb=New notesdatabase(mdb(0),mdb(1))

Set caldoc = maildb.CreateDocument
caldoc.Form = "Appointment"
If doc.datefrom(0) =doc.dateto(0) Then
 
 
 caldoc.Subject = "Holiday " & doc.datefrom(0)  
Else
 caldoc.Subject = "Holiday " & doc.datefrom(0) & "-" & doc.dateto(0)
End If
Dim rt As New notesrichtextitem(caldoc,"Body")
Call rt.appendtext("Holiday for " & doc.Requester(0) )
Call rt.addnewline(1)
Call rt.appendtext("Status: " & doc.statusflag(0) )
Call rt.addnewline(1)
Call rt.appenddoclink(doc,"Link to Request" )

caldoc.Subject = "Holiday " & doc.datefrom(0) & "-" & doc.dateto(0)
caldoc.AppointmentType = "2"
Call caldoc.replaceitemvalue("StartDate", doc.datefrom(0))
Call caldoc.replaceitemvalue("StartDateTime", doc.datefrom(0))
Call caldoc.replaceitemvalue("EndDate", doc.dateto(0))
Call caldoc.replaceitemvalue("EndDateTime", doc.dateto(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.datefrom(0) + " " + "08:00 AM")
Set endTime = New NotesDateTime(doc.dateto(0) + " " + "08:00 AM")
Redim varCDT(0) As notesdatetime
Set varCDT(0)=New notesdatetime(datetime.zonetime)
Call datetime.adjustday(1)
count=1
Do Until datetime.timedifferencedouble(endtime)>0
 Redim Preserve varCDT(count)
 Set varcdt(count)=New notesdatetime(datetime.zonetime)
 Call datetime.adjustday(1)
 count=count+1
Loop


Set CDT = caldoc.ReplaceItemValue("CalendarDateTime", varcdt)
Call caldoc.computewithform(False,False)
Call caldoc.Save(False,False)

Call uiw.EditDocument(False,caldoc)

End

errhdlr:
Print Error$ & " at line " & Erl
End

 

 

 Jump to:     Notes Tips
    Lotus Notes Index 
  Register for Tips
Previous Lotus Notes Tip 
    Next Lotus Notes Tip
Your company logo here?
Adam Foster
Free Cash Making Web Site
Free Revenue Earning Blog Site
 Free Revenue Earning Newsletter Site   
Free Search Pages Free Web stats
Free Contact Us page
Cheap .com domain names
 Need a website or 
   Lotus Notes
  problem solved?
Adam Foster
Lotus Notes and Domino 6 Programming Bible by Brian Benz, Rocky Oliver
Covers all the programming techniques, concepts, and languages used with Notes and Domino, as well as the many new features of Domino 6 Thoroughly examines the Notes and Domino role with Java, XML, Web services, and other IBM products and technologies Provides extensive code and examples, many geared to the needs of administrators High-profile authors, known to their audience through conferences and articles Companion Web site shows example applications from the book running on a live Domino server and provides code download.
See at: Amazon.co.uk | Amazon.com |