Manage Learn to apply best practices and optimize your operations.

LotusScript to create repeating reminders in a Lotus Notes calendar

When triggered from within a mail file in Lotus Domino R6, this LotusScript code from SearchDomino.com Hall of Famer Blessan Philip will set a repeating reminder in a user's Lotus Notes calendar.

VIEW MEMBER FEEDACK TO THIS TIP

When triggered from within a mail file in Lotus Domino R6, this LotusScript code will set a repeating reminder for every Friday at 10 a.m. in a user's Lotus Notes calendar. If a previous reminder already exists -- from being created previously from this code -- it will delete that repeating reminder and create a new one.

Use the 'No_of_week' variable to increase the repeating weeks for which the reminder is set, e.g. 10 for 10 weeks.

Nb: Maximum number of weeks up to which it worked was 33. Use the 'subjt' variable to set the subject of the reminder. Now, use the 'pop_Str' variable to set the alarm pop-up.

This LotusScript code can be incorporated into a hotspot button, embedded in an email that you can send out. Clicking on this button will create repeating reminder entries in the receiver's Lotus Notes mail calendar.

With little modification of this LotusScript code, you can also schedule it to run overnight, maybe at a gap of one month duration, which can create repeating reminder entries on mail files.

Dim userMailDb  As NotesDatabase
Dim Sess As NotesSession
Dim UsrName As notesname '
'get the user name Dim Parent_Rdoc 
As  NotesDocument Dim Response_Rdoc 
As NotesDocument 
Dim ExcludeFromView(1) As String 


Sub Click(Source As Button)
Dim startupDate As NotesDateTime
Dim endDate As NotesDateTime
Dim  AllDtTime() As notesdatetime
Dim tempDt As NotesDateTime


Dim i As Integer
Dim No_of_week As Integer 
Dim subjt As String 
Dim pop_Str As String 


'==================================
===============================
'setting up of important variable
No_of_week=10 ' Reminder will 
work for this number of weeks 
subjt="Reminder"
pop_Str="Don't forget to 
fillup your timesheet - Support Office"
'==================================
===============================
'==================================
===============================
'Setting global objects & variables
Set Sess=New notessession
Set userMailDb=sess.currentdatabase
Set UsrName=
New NotesName(sess.UserName) 
ExcludeFromView(0)="D"
ExcludeFromView(1)="S"
'==================================
=============================== 

'validation
Call DeletePreviousActive
 
 
'==================================
===================================
==========
'Sets the startupdate as the current 
friday at 10:00 AM & end date to 20 weeks after that 
currDay=Weekday(Now) 
Set startupDate=New NotesDateTime(Now)

Startupdate.AdjustDay(6-currDay) '6 is for friday
Set startupDate=New NotesDateTime
(Cstr(startupDate.DateOnly)+ " " +Cstr("10:00 AM")) 
Set tempDt=New NotesDateTime
(Cstr(startupDate.DateOnly)+ " " 
+Cstr(StartupDate.TimeOnly))
Set endDate =New NotesDateTime
(Cstr(startupDate.DateOnly)+ " " 
+Cstr(StartupDate.TimeOnly))
Call endDate.AdjustDay(((No_of_week-1)*7)) 
'===================================
===================================
===========
'===================================
===================================
===========
'Calculates the all the date times 
at a gap of 7 days i.e. each friday 
which falls between start & end date
i=0 
While (endDate.timedifference
(tempDt)>=0)'Cdat(tempDt.DateOnly)<=
Cdat(endDate.DateOnly)
Redim Preserve AllDtTime(i) 
As NotesDateTime  
Set AllDtTime(i)=New NotesDateTime
(Cstr(TempDt.DateOnly)+" "+Cstr(TempDt.TimeOnly))  
Call TempDt.AdjustDay(7)
i=i+1
Wend
Call TempDt.AdjustDay(-7)
Set endDate=New NotesDateTime
(Cstr(TempDt.DateOnly)+" "+Cstr(TempDt.TimeOnly))
'==================================
====================================
=================
 
' pass in start date time, end date 
time of the reminderappointment, 
subject, popup string, name of user , and session.
'Creates the parent note of the reminder
Call CreateParentNote
(startupDate, endDate,pop_Str, subjt , AllDtTime)
'Creates the response note of the reminder
Call createResponseNote
(startupDate, endDate,pop_Str, subjt , AllDtTime)

Msgbox "Timesheet Reminder 
added to your calendar",64,"Add 
TimeSheet Reminder -"+userMailDb.Title
 
End Sub
Sub CreateParentNote( dateTime 
As notesDateTime, EndDt As NotesDateTime, 
popUpStr As String, subjectStr As 
String, AllDateTime As Variant)
' pass in start date time, end date time 
of the reminder, subject, 
popup string, name of user , and session.
 
'create reminder doc
 
Set  Parent_Rdoc=userMailDb.CreateDocument

With Parent_Rdoc
.ReplaceItemValue "TimeSheetReminder","1"   
'Added for searching
.ReplaceItemValue "$Alarm", 1
.ReplaceItemValue "$AlarmDescription", popUpStr
.ReplaceItemValue "$AlarmMemoOptions", ""
.ReplaceItemValue "$AlarmOffset", -1 
'pop up 1 minute before the time specified..
.ReplaceItemValue "$AlarmSound","tada"
.ReplaceItemValue "$AlarmUnit", "M"
.Replaceitemvalue "$AltPrincipal",
Cstr(UsrName.Canonical)
.Replaceitemvalue "$CSFlags","c"
.Replaceitemvalue "$CSVersion","2"
.Replaceitemvalue "$NoPurge",Enddt
.Replaceitemvalue "$PublicAccess","1"
.Alarms = "1"
.AltChair=UsrName.Canonical
.AppointmentType = "4" '4 for reminder
.ApptUNID=Cstr(Parent_Rdoc.UniversalID)
.Chair=Cstr(UsrName.Canonical)
.EndDate = dateTime.DateOnly 
' As per output this is startup date only
.EndDateTime=dateTime.lsLocaltime  
'As per output , this startup date time 
i.e. first entry in parent note
.EndTime = dateTime.TimeOnly
.ExcludeFromView = ExcludeFromView 
'"D;S" ' keeps items out of the draft view.  
.Form = "Appointment"
.Replaceitemvalue "From",UsrName.Canonical
.MeetingType="1"
.OrgRepeat="1"
.OrgTable="C0"
.Principal=Cstr(UsrName.Canonical) 
.RepeatCustom=AllDateTime  
'should be all the dates without times
.RepeatDates=AllDateTime  'All the date times
.RepeatEndDates=AllDateTime  'All the date times
.RepeatFor=5
.RepeatForUnit=""
.RepeatFromEnd=""
.RepeatHow="F"
.RepeatInstanceDates=AllDateTime
.RepeatInterval="1"
.Repeats="1"
.RepeatStartDate=dateTime.lsLocaltime
.RepeatUnit="C"
.RepeatUntil=EndDt.lsLocaltime 
.RepeatWeekends="D"
.SchedulerSwitcher="1" 
.SequenceNum=1
.StartDate = dateTime.lsLocaltime
.StartTime = dateTime.TimeOnly
.STARTDATETIME=dateTime.lsLocaltime 
.Subject = subjectStr
.tmpAdditionalInviteeButton="1"
.tmpAdditionalRoomsButton="1"
.tmpAppointmentType="Reminder"
.tmpAppointmentType_1="Reminder"
.tmpChair=Usrname.Canonical
.tmpEventLabel="Reminder"
.tmpOwnerHW="0"
.tmpParticipantHW="1"
.tmpRW="1"
.tmpShowTZ="0"
.txtNum="5"
.UpdateSeq=1
.WebDateTimeInit="1"
.ReplaceItemValue "_viewIcon", 10 

.ComputeWithForm True,False
 
.Save True, False 
'.PutInFolder( "$Alarms" ) 
End With 
'*************************************************
**************************************************
**************************************************
**************************************************** 
 
End Sub
Sub createResponseNote( dateTime 
As notesDateTime, EndDt As NotesDateTime,
 popUpStr As String, subjectStr As String, 
AllDateTime As Variant) ' pass in start date 
time, end date time of the reminder, subject, 
popup string, name of user , and session.
 
Set Response_Rdoc=
userMailDb.CreateDocument
Call Response_Rdoc.MakeResponse
(Parent_Rdoc) 'making response document 

With Response_Rdoc
.ReplaceItemValue "TimeSheetReminder","1"   
'Added for searching
.ReplaceItemValue "$Alarm", 1
.ReplaceItemValue "$AlarmDescription", popUpStr
.ReplaceItemValue "$AlarmMemoOptions", ""
.ReplaceItemValue "$AlarmOffset", -1 
'pop up 1 minute before the time specified..
.ReplaceItemValue "$AlarmSound","tada"
.ReplaceItemValue "$AlarmUnit", "M"
.Replaceitemvalue "$AltPrincipal",Cstr(UsrName.Canonical)
.Replaceitemvalue "$CSFlags","i"
.Replaceitemvalue "$CSVersion","2"
.Replaceitemvalue "$NoPurge",Enddt
.Replaceitemvalue "$PublicAccess","1"
.Replaceitemvalue "$RefOptions","1"
'.Replaceitemvalue "$Ref",   'it gets automatically created.
.Alarms = "1"
.AltChair=UsrName.Canonical
.AppointmentType = "4" '4 for reminder
.ApptUNID=Cstr(Parent_Rdoc.UniversalID) 
' universal id of the parent document
.CalendarDateTime=AllDateTime 
'All the date times
.Chair=Cstr(UsrName.Canonical)
.EndDate = dateTime.DateOnly 
' As per output this is startup date only  
.EndDateTime= AllDateTime 
'As per output in response document , 
this is all the date time
.EndTime = dateTime.TimeOnly
.ExcludeFromView = ExcludeFromView 
' keeps items out of the draft view.  
.Form = "Appointment"
.Replaceitemvalue "From",UsrName.Canonical
.MeetingType="1"
.OrgRepeat="1"    
.OrgTable="C0"
.Principal=Cstr(UsrName.Canonical)   
.RepeatInstanceDates=AllDateTime 
' all date time
.Repeats="1"
.SchedulerSwitcher="1"
.SequenceNum=1
.StartDate = dateTime.lsLocaltime
.StartTime = dateTime.TimeOnly
.STARTDATETIME=AllDateTime 
' all date time 
.Subject = subjectStr
.txtNum="5"
.UpdateSeq=1
.WebDateTimeInit="1"
.ReplaceItemValue "_viewIcon", 10  
.ComputeWithForm True,False
.Save True, False 
.PutInFolder( "$Alarms" ) 
End With 
'******************************************
********************************************
*********************************************
**********************************************
************************ 
 
End Sub
Sub DeletePreviousActive
Dim SrchStr As String 
Dim doccoll As NotesDocumentCollection
Dim doc As NotesDocument
Dim AppView As NotesView 

SrchStr={TimeSheetReminder = "1" }

Set AppView=userMaildb.GetView("($ApptUNID)")
Set doccoll=usermaildb.Search(SrchStr,Nothing,1)

Call doccoll.RemoveAll(True)
 
End Sub

MEMBER FEEDBACK TO THIS TIP

We've had several users write in and ask for this code in its full format. You can now access it by clicking here to view it in its original format. If you have any further questions, please don't hesitate to write me.
—Matt Gervais, Assistant Site Editor SearchDomino.com

Do you have comments on this tip? Let us know.

Related information from SearchDomino.com:

  • Learning Guide: LotusScript development
  • FAQ: LotusScript advice
  • Reference Center: LotusScript tips and resources

    This tip was submitted to the SearchDomino.com tip library by member Blessan Philip. Please let others know how useful it is via the rating scale below. Do you have a useful Lotus Notes, Domino, Workplace or WebSphere tip or code snippet to share? Submit it to our monthly tip contest and you could win a prize.

  • Dig Deeper on LotusScript

    Start the conversation

    Send me notifications when other members comment.

    Please create a username to comment.

    -ADS BY GOOGLE

    SearchWindowsServer

    Search400

    • iSeries tutorials

      Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

    • V6R1 upgrade planning checklist

      When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

    • Connecting multiple iSeries systems through DDM

      Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

    SearchDataCenter

    SearchContentManagement

    Close