Solved

Add Reminder to Calendar

Posted on 2001-06-05
11
421 Views
Last Modified: 2013-12-18
I'm busy creatinf a workflow application.
I want to add a button to my form that will prompt the user to enter a date and time.
I then want to add a reminder to the users Calendar for the date and time that they entered.
I have a field on my form called Subject. I want this field to appear in the appointment Subject and Body.

Can you please give me the code to do this.

Thank you,
Robin
0
Comment
Question by:MossRobin
  • 6
  • 5
11 Comments
 
LVL 4

Expert Comment

by:sloeber
ID: 6155606
Here's an example of how to do something like that
This button is on the STP Form, which creates a calendar entry into the person's mail)

Sub Click(Source As Button)
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Set uidoc = workspace.CurrentDocument
Set doc = uidoc.Document

DocUNID = doc.STP_DocUNID(0)
url = "http://server.com/crm/salesprocess.nsf/0/" + DocUNID + "?OpenDocument"
ReminderAccountName = doc.STP_AccountName(0)
ReminderStrategy = doc.STP_StrategyTitle(0)
ReminderWho = doc.STP_Who(0)
ReminderDate = doc.STP_Date(0)
RTime = doc.STP_Time(0)
If RTime = "" Then
ReminderTime = "9:00:00 AM"
Else
ReminderTime = RTime
End If
FullDate = Str(ReminderDate) + " " + Str(ReminderTime) + " " + "ZE8"
Dim DateTime As New NotesDateTime(FullDate)
Dim IsTime As Variant
IsTime = DateTime.LSLocalTime

Dim session As New NotesSession
Dim user As String
user = session.CommonUserName

Dim dbnab As NotesDatabase
Dim view As notesview
Dim docnab As NotesDocument
Set dbnab = New NotesDatabase( "Spider", "names.nsf" )
Set view = dbnab.GetView("People")
Set docnab = New notesdocument(dbnab)
Set docnab = view.getdocumentbykey(user)

If (docnab Is Nothing) Then
Print "No Matching Document"
Else
dbname = docnab.MailFile(0)
Set dbmailfile = New notesdatabase("Spider", dbname)
Set docnab = dbmailfile.CreateDocument
docnab.Form = "Appointment"
docnab.AppointmentType = "4"
docnab.Subject = ReminderStrategy + " - " + ReminderWho + " (" + ReminderAccountName + ")"
docnab.StartDate = IsTime
docnab.StartTime = IsTime
docnab.StartDateTime = IsTime
docnab.CalendarDateTime = IsTime
docnab.Principal = user
docnab.Body = "Please click on this link for more information : " + url
Call docnab.Save( True, True )
End If
End Sub


I hope that this help you
Greets,
Sloeber
0
 

Author Comment

by:MossRobin
ID: 6155673
Thanks, I'm testing it...
It doesn't make all that much sence to me.

Will come back as soon as I have a problem or am happy with it.

Regards,
Robin
0
 

Author Comment

by:MossRobin
ID: 6155764
OK I have a Problem !!!!!!!!!!!!!!!
I have included my code for the button.
I make an entry to the Calendar but it isn't a reminder...
If I goto Options Tab Notify me is NOT checked.
If I check it, a dialog box opens and ask me to enter minutes before the time the alarm must go off.
I need to enter this automatically too.

Please help again.
If possible please make mods to my code.

Thanks,
Robin

Sub Click(Source As Button)
     On Error Goto errhandle    
     Dim session As New NotesSession
     Dim db As NotesDatabase
     Dim doc As NotesDocument
     Set db = New NotesDatabase ("RCBG01NT","mail\rmoss.nsf")
     Set doc = db.CreateDocument
     Dim workspace As New NotesUIWorkspace
     Dim uidoc As NotesUIDocument
     Dim IsTime As Variant
     IsTime = "05/06/2001 14:00:00 PM"
     Set uidoc = workspace.CurrentDocument
     Set doc2 = uidoc.Document
     doc.Form = "Appointment"
     doc.AppointmentType = "4"
     doc.Subject = "Modified Script"
     doc.StartDate = IsTime
     doc.StartTime = IsTime
     doc.StartDateTime = IsTime
     doc.CalendarDateTime = IsTime
     doc.Principal = "Robin Moss"
     doc.Body = "Please click on this link for more information : " + url
     Call doc.Save( True, True )
     Exit Sub
     
Errhandle:
     Msgbox "Line " & Erl
     
End Sub
0
 
LVL 4

Expert Comment

by:sloeber
ID: 6155802
I must go away no for an appointment.
But you can add this to your code
doc.Alarms="1"
and may be it's also necessary to add
doc.$AlarmDisabled="1"
I didn't test it.
It is also possible that you must add an ~ before the $
doc.~$AlarmDisabled="1"

Greets,
Sloeber
0
 
LVL 4

Expert Comment

by:sloeber
ID: 6155828
i figured it out;
And this are the remarks.
The following fields should be set: $AlarmDescription, $AlarmTime, $Alarm and doc.Alarm (separate fields)
There are 2 more things that must be done before the alarm will trigger.
1. Check to see if the Reminder document has a field called $AlarmDisabled.
If doc.HasItem("$AlarmDisabled") Then
doc.RemoveItem("$AlarmDisabled")
End if
2. YOU MUST PUT THE REMINDER DOCUMENT IN THE ALARM FOLDER
after you've created and saved the entry:
Call doc.PutInFolder("$Alarms", True)
These things should trigger the alarm at the right times. Depending on how you've written your code you might need to play around with the code to get it to work properly.

I hope it helps.

Greets,
Sloeber
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:MossRobin
ID: 6156125
Hi, thanks for the help...
It still isn't working yet. Something I've noticed is that my reminder appears as a DRAFT. It is in my DRAFT view and it has a draft icon on a reminder icon in the All Docs view. This is even with the code at the end to move it to the $Alarm folder.

I think if I can just get it in the $Alarm folder it'll work. I've tried making the $Alarm folder vissible to see if I can see it there and I cannot. What I did was open my mail file in Designer and goto the folder design and click the refresh button to see what is in there. There are other entries but not the ones I'm creating...

If I open the reminder in my draft view and click save and close, it appears in the $Alarm view.

PLEASE HELP. I've increased the question to 600 points.
here is the code I'm currently using.

Thanks,
Robin

Sub Click(Source As Button)
     On Error Goto errhandle    
     Dim session As New NotesSession
     Dim db As NotesDatabase
     Dim doc As NotesDocument
     Set db = New NotesDatabase ("RCBG01NT","mail\rmoss.nsf")
     Set doc = db.CreateDocument
     Dim workspace As New NotesUIWorkspace
     Dim uidoc As NotesUIDocument
     Dim IsTime As Variant
     IsTime = "05/06/2001 16:25:00 PM"
     Msgbox ("isdate = " + IsTime)
     Set uidoc = workspace.CurrentDocument
     Set doc2 = uidoc.Document
     Dim RefNo
     doc.Form = "Appointment"
     doc.AppointmentType = "4"
     doc.Subject = "Modified Script"
     doc.StartDate = IsTime
     doc.StartTime = IsTime
     doc.StartDateTime = IsTime
     doc.CalendarDateTime = IsTime
     doc.Principal = "Robin Moss"
     doc.Body = "Please click on this link for more information : " + url
     doc.~$Alarm = "1"
     doc.~$AlarmDisabled = "0"    
     doc.~$AlarmOffset = -10
     doc.~$AlarmTime = IsTime
     doc.~$AlarmDescription = "Occupational Hygiene Control"    
     doc.Alarms = "1"
     doc.Alarm = "1"
     
     If doc.HasItem("$AlarmDisabled") Then
          doc.RemoveItem("$AlarmDisabled")
     End If    
     Call doc.Save( True, True )
     
     Call doc.PutInFolder("($Alarms)", True)
     Exit Sub
     
Errhandle:
     Msgbox "Line " & Erl & Error
     
End Sub
0
 

Author Comment

by:MossRobin
ID: 6156146
Sloeber it wont let me increase the points to more that 300...
We'll make a plan and open another question and accept your comments. Once this is done.

Thanks for the help !!

Robin
0
 

Author Comment

by:MossRobin
ID: 6156193
Sloeber it wont let me increase the points to more that 300...
We'll make a plan and open another question and accept your comments. Once this is done.

Thanks for the help !!

Robin
0
 
LVL 4

Expert Comment

by:sloeber
ID: 6156723
I figure it out almost.
The problem is with your date/time value.
Now, is your document visible in the folder alarms and the view calendar.
But he dopn't let you see your document because your type of IsTime is wrong
Here's my code.
Tommorriw you'll have the correct solution
On Error Goto errhandle    
     Dim session As New NotesSession
     Dim db As NotesDatabase
     Dim doc As NotesDocument
     Set db = New NotesDatabase ("servername","mail\test.nsf")
     Set doc = db.CreateDocument
     Dim IsTime As Variant
     IsTime = "05-06-2001 16:25:00"
     Dim RefNo
     doc.Form = "Appointment"
     doc.AppointmentType = "4"
     doc.Subject = "Modified Script"
     doc.StartDate = IsTime
     doc.StartTime = IsTime
     doc.StartDateTime = IsTime
     doc.CalendarDateTime = IsTime
     doc.Principal = "Robin Moss"
     doc.Body = "Please click on this link for more information : "
     doc.~$Alarm = "1"
     doc.Excludefromview = "D"
     doc.~$AlarmOffset = -10
     doc.~$AlarmTime = IsTime
     doc.~$AlarmDescription = "Occupational Hygiene Control"    
     doc.Alarms = "1"
     doc.Duration = 1
     doc.OrgConfidential = "0"
     doc.BookFreeTime = "0"
     doc.~_ViewIcon = 10
     doc.OrgTable = "CO"
     If doc.HasItem("$AlarmDisabled") Then
          doc.RemoveItem("$AlarmDisabled")
     End If    
     Call doc.PutInFolder("$Alarms", True)
     
     Call doc.Save( True, True )
     
     Call doc.PutInFolder("$Alarms", True)
     
     Exit Sub
     
Errhandle:
     Msgbox "Line " & Erl & Error
     

greets,
sloeber
0
 
LVL 4

Accepted Solution

by:
sloeber earned 300 total points
ID: 6156821
JOEPIIIIIIIIIIIIEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
It works, here's the final solution

Sub Initialize
On Error Goto errhandle    
     Dim session As New NotesSession
     Dim db As NotesDatabase
     Dim doc As NotesDocument
     Set db = New NotesDatabase ("RCBG01NT","mail\rmoss.nsf")
     Set doc = db.CreateDocument
     Dim IsTime As New NotesDateTime( "05/06/2001 20:30" )
     Dim RefNo
     doc.Form = "Appointment"
     doc.AppointmentType = "4"
     doc.Subject = "Modified Script"
     Set doc.StartDate = IsTime
     Set doc.StartTime = IsTime
     Set doc.CalendarDateTime = IsTime
     Set doc.StartDateTime = IsTime
     doc.Principal = "Robin Moss"
     doc.Body = "Please click on this link for more information : "
     doc.~$Alarm = "1"
     doc.Excludefromview = "D"
     doc.~$AlarmOffset = -10
     doc.~$AlarmTime = IsTime.LocalTime
     doc.~$AlarmDescription = "Occupational Hygiene Control"    
     doc.Alarms = "1"
     doc.Duration = 1
     doc.OrgConfidential = "0"
     doc.BookFreeTime = "0"
     doc.~_ViewIcon = 10
     If doc.HasItem("$AlarmDisabled") Then
          doc.RemoveItem("$AlarmDisabled")
     End If    
     Call doc.PutInFolder("$Alarms", True)
     
     Call doc.Save( True, True )
     
     Call doc.PutInFolder("$Alarms", True)
     
     Exit Sub
     
Errhandle:
     Msgbox "Line " & Erl & Error
     
End Sub

Greets,
Sloeber
0
 

Author Comment

by:MossRobin
ID: 6158606
Thanks Sloeber, your last proposal is 100%.
Thanks for the help.
Robin
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

For Desktop Techs: How to retain a user's Notes configuration data when swapping out the end user's computer. (Assuming that you are not upgrading to a completely different version of Notes client) All you need to do is: 1) install Notes o…
This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now