magnex
asked on
How can I create an appointment from another database
Hey experts,
I've a problem.
I've a purchase database, and in this database I've a lot of information about my customers.
In that document I've a date field (for my next appointment with that customer) and a subject field.
What I want is an action button, that when I click on it, it makes an appointment in my calendar (mail db), the date from the appointment and the subject are available in the document.
How can I do this ?
I've a problem.
I've a purchase database, and in this database I've a lot of information about my customers.
In that document I've a date field (for my next appointment with that customer) and a subject field.
What I want is an action button, that when I click on it, it makes an appointment in my calendar (mail db), the date from the appointment and the subject are available in the document.
How can I do this ?
You say that you have the date and subject available in the customer document in the purchase database. Does the date field include a time for this appointment? The above code from Bozzie4 will probably work with some small changes to get the date information from your customer document, but it will need a "time" to create the appointment. If this will only be a reminder, then this can be done with only the date and appending " 12:00:00 AM" to the date when creating the NotesDateTime object. Sounds a little complicated, but that's the way the calendar entries work in Notes.
Tell us what you need for the appointment document.
HS
Tell us what you need for the appointment document.
HS
Magnex,
I need the field names for Subject and the apopintment date field. If you have acess to designer, that will be easy to find. Otherwise:
* highlight the document in the view
* choose File -> Database -> Properties
* change "database" to "document" in the proerties title
* click on the second tab ("triangle" tab)
* in the left half, scroll to the top
* click on each field name on the left, and see if the value matches subject or the date on the right. Tell me those field names.
I need the field names for Subject and the apopintment date field. If you have acess to designer, that will be easy to find. Otherwise:
* highlight the document in the view
* choose File -> Database -> Properties
* change "database" to "document" in the proerties title
* click on the second tab ("triangle" tab)
* in the left half, scroll to the top
* click on each field name on the left, and see if the value matches subject or the date on the right. Tell me those field names.
Const SubjectField = "SUBJECT" 'change as appropriate
Const DateField = "APPOINTMENT" 'chaneg as appropriate
Dim ws as new notesUiWorkspace
Dim uiDoc as notesUiDocument
Set uiDoc = ws.currentDocument
Dim Subject as string, position as string
Subject = uiDoc.fieldGetText(Subject Field)
Position = uiDoc.FieldGetText(DateFie ld)
If ucase(right(Position,1)) <> "M" then Position = position & " 9:00 AM"
Dim s As new notesSession
Dim db As notesDatabase
Set db = s.getDatabase("", "")
db.openMailDB
Dim doc As notesDocument
Set doc = db.createDocument
doc.replaceItemvalue "Form", "Appointment"
Dim dateTime As NotesDateTime
Set dateTime = s.createDateTime(position)
doc.replaceItemvalue "$Alarm", 1
doc.replaceItemvalue "$AlarmOffset", 0
MsgBox "Setting reminder/alarm - " & dateTime.lslocalTime & " - " & Subject
doc.replaceItemvalue "startDateTime", dateTime
doc.replaceItemvalue "endDateTime", dateTime
doc.replaceItemvalue "calendarDateTime", dateTime
doc.replaceItemvalue "Subject", Subject
doc.replaceItemvalue "startTime", dateTime
doc.replaceItemvalue "appointmentType", "3"
doc.replaceItemvalue "Alarms", "1"
doc.replaceItemvalue "startDate", dateTime
doc.replaceItemvalue "endDate", dateTime
doc.replaceItemvalue "endTime", dateTime
doc.replaceItemvalue "SendTo", invitees
doc.Save True, True
doc.putInFolder "($Alarms)"
Const DateField = "APPOINTMENT" 'chaneg as appropriate
Dim ws as new notesUiWorkspace
Dim uiDoc as notesUiDocument
Set uiDoc = ws.currentDocument
Dim Subject as string, position as string
Subject = uiDoc.fieldGetText(Subject
Position = uiDoc.FieldGetText(DateFie
If ucase(right(Position,1)) <> "M" then Position = position & " 9:00 AM"
Dim s As new notesSession
Dim db As notesDatabase
Set db = s.getDatabase("", "")
db.openMailDB
Dim doc As notesDocument
Set doc = db.createDocument
doc.replaceItemvalue "Form", "Appointment"
Dim dateTime As NotesDateTime
Set dateTime = s.createDateTime(position)
doc.replaceItemvalue "$Alarm", 1
doc.replaceItemvalue "$AlarmOffset", 0
MsgBox "Setting reminder/alarm - " & dateTime.lslocalTime & " - " & Subject
doc.replaceItemvalue "startDateTime", dateTime
doc.replaceItemvalue "endDateTime", dateTime
doc.replaceItemvalue "calendarDateTime", dateTime
doc.replaceItemvalue "Subject", Subject
doc.replaceItemvalue "startTime", dateTime
doc.replaceItemvalue "appointmentType", "3"
doc.replaceItemvalue "Alarms", "1"
doc.replaceItemvalue "startDate", dateTime
doc.replaceItemvalue "endDate", dateTime
doc.replaceItemvalue "endTime", dateTime
doc.replaceItemvalue "SendTo", invitees
doc.Save True, True
doc.putInFolder "($Alarms)"
I'm telling ya, calendar entries are tricky. You must have specific values in all 6 fields:
StartDateTime
StartDate
StartTime
EndDateTime
EndDate
EndTime
Each one needs the value for the component:
StartDateTime needs a value like 08/12/2003 04:00:00 AM
StartDate needs a value like 08/12/2003
StartTime needs a value like 04:00:00 AM
and so on.
If all this is correct, the calendar will display the document correctly.
HS
StartDateTime
StartDate
StartTime
EndDateTime
EndDate
EndTime
Each one needs the value for the component:
StartDateTime needs a value like 08/12/2003 04:00:00 AM
StartDate needs a value like 08/12/2003
StartTime needs a value like 04:00:00 AM
and so on.
If all this is correct, the calendar will display the document correctly.
HS
ASKER
when I use the above code I get the error "Not a sub or function name OpenMailDb"
It's
Call db.OpenMail
instead of db.openmaildb
cheers,
tom
Call db.OpenMail
instead of db.openmaildb
cheers,
tom
ASKER
I still get an error "Not a member Openmaildb"
ASKER
bozzie when I ty your code
He makes a calendar entry, but I can't open it.
"Error trying to open document : Note item not found"
"Field StartDate_2: Array index out of bounds"
He makes a calendar entry, but I can't open it.
"Error trying to open document : Note item not found"
"Field StartDate_2: Array index out of bounds"
ASKER
in the example of qwaletee the problem with openmail is solved.
But, he creates now a meeting document in the calendar instead of an appointment.
But, he creates now a meeting document in the calendar instead of an appointment.
Add the line
Call doct.ReplaceItemValue("End DateTime" , ndt1 )
before the 'computewithform'
Should've tested it myself first, of course :-)
cheers,
Tom
Call doct.ReplaceItemValue("End
before the 'computewithform'
Should've tested it myself first, of course :-)
cheers,
Tom
And to create an appointment document, change
doc.replaceItemvalue "appointmentType", "3"
to
doc.replaceItemvalue "appointmentType", "0"
cheers,
Tom
doc.replaceItemvalue "appointmentType", "3"
to
doc.replaceItemvalue "appointmentType", "0"
cheers,
Tom
ASKER
Bozzie, In your example I still get the same problem.
He also shows no time in the calendar and he makes the appointment every week again
The other example, he makes no the appointment but gives me the error "Error trying to open the document : noteitem not found" when I try to open the document but I can open the document
He also shows no time in the calendar and he makes the appointment every week again
The other example, he makes no the appointment but gives me the error "Error trying to open the document : noteitem not found" when I try to open the document but I can open the document
Hmmm. This works for me like a charm, though.
So this code should do it for you.
Dim s As NotesSession
Dim Adb As notesdatabase
Dim maildb As notesdatabase
Dim view As notesview
Dim w As notesUiworkspace
Dim doc As notesdocument
Dim doct As notesdocument
Dim reg As New NotesRegistration
Dim uname As String
Dim retmailserver As String
Dim retmailfile As String
Dim nm As String
Dim t As String
Set s =New NotesSession
nm=s.username
Set w=New NotesUIWorkspace
Set doc=w.currentdocument.docu ment
Dim userName As New NotesName(nm)
uname=UserName.Abbreviated
t=s.currentdatabase.server
reg.RegistrationServer = s.currentdatabase.server
Call reg.GetUserInfo(uname, retmailserver, retmailfile)
Set MailDb=New NotesDatabase(retmailserve r, retmailfile)
Set doct=maildb.CreateDocument
Call doct.replaceItemValue("For m","Appoin tment")
Call doct.replaceItemValue("ReA ssignMark" ,"Yes")
Call doct.replaceItemValue("App ointmentTy pe","0") '0 for Appointment
Call doct.replaceItemValue("Sub ject", " SUBJECT GOES HERE ")
Call doct.replaceItemValue("$Al armUnit", "M")
Call doct.replaceItemValue("$Al arm", 1)
Call doct.replaceItemValue("$Al armMemoOpt ions", "")
Call doct.replaceItemValue("$Al armDescrip tion", "")
Call doct.replaceItemValue("$Al armOffset" , -1)
Dim ndt As NotesDateTime
t=Cstr(Datevalue(Today))+" 13:15:00"
Set ndt = New NotesDateTime(t)
Dim ndt1 As NotesDateTime
t=Cstr(Datevalue(Today))+" 13:20:00"
Set ndt1 = New NotesDateTime(t)
Call doct.replaceItemValue("STA RTDATETIME ", ndt)
Call doct.replaceItemValue("Sta rtTime", ndt)
Call doct.replaceItemValue("End Time", ndt1)
Call doct.replaceItemValue("Sta rtDate", ndt)
Call doct.replaceItemValue("End Date", ndt1)
Call doct.replaceItemValue("Cal endarDateT ime", ndt)
Call doct.ReplaceItemValue("End DateTime" , ndt1
' ###
Call doct.ComputeWithForm(True, True)
' use this when done testing:
'Call doct.ComputeWithForm(True, False)
'###
Call doct.Save(True,True)
cheers,
Tom
So this code should do it for you.
Dim s As NotesSession
Dim Adb As notesdatabase
Dim maildb As notesdatabase
Dim view As notesview
Dim w As notesUiworkspace
Dim doc As notesdocument
Dim doct As notesdocument
Dim reg As New NotesRegistration
Dim uname As String
Dim retmailserver As String
Dim retmailfile As String
Dim nm As String
Dim t As String
Set s =New NotesSession
nm=s.username
Set w=New NotesUIWorkspace
Set doc=w.currentdocument.docu
Dim userName As New NotesName(nm)
uname=UserName.Abbreviated
t=s.currentdatabase.server
reg.RegistrationServer = s.currentdatabase.server
Call reg.GetUserInfo(uname, retmailserver, retmailfile)
Set MailDb=New NotesDatabase(retmailserve
Set doct=maildb.CreateDocument
Call doct.replaceItemValue("For
Call doct.replaceItemValue("ReA
Call doct.replaceItemValue("App
Call doct.replaceItemValue("Sub
Call doct.replaceItemValue("$Al
Call doct.replaceItemValue("$Al
Call doct.replaceItemValue("$Al
Call doct.replaceItemValue("$Al
Call doct.replaceItemValue("$Al
Dim ndt As NotesDateTime
t=Cstr(Datevalue(Today))+"
Set ndt = New NotesDateTime(t)
Dim ndt1 As NotesDateTime
t=Cstr(Datevalue(Today))+"
Set ndt1 = New NotesDateTime(t)
Call doct.replaceItemValue("STA
Call doct.replaceItemValue("Sta
Call doct.replaceItemValue("End
Call doct.replaceItemValue("Sta
Call doct.replaceItemValue("End
Call doct.replaceItemValue("Cal
Call doct.ReplaceItemValue("End
' ###
Call doct.ComputeWithForm(True,
' use this when done testing:
'Call doct.ComputeWithForm(True,
'###
Call doct.Save(True,True)
cheers,
Tom
ASKER
I used a mix of Bozzies solutions and qwaletee solution.
Everything works now fine in the client but not in the browser.
UI classes are not allowed in the browser.
So, my question is can we do the same in the browser
Everything works now fine in the client but not in the browser.
UI classes are not allowed in the browser.
So, my question is can we do the same in the browser
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Dim s As NotesSession
Dim Adb As notesdatabase
Dim maildb As notesdatabase
Dim view As notesview
Dim w As notesUiworkspace
Dim doc As notesdocument
Dim doct As notesdocument
Dim reg As New NotesRegistration
Dim uname As String
Dim retmailserver As String
Dim retmailfile As String
Dim nm As String
Set s =New NotesSession
nm=s.username
Set w=New NotesUIWorkspace
Set doc=w.currentdocument.docu
Dim userName As New NotesName(nm)
uname=UserName.Abbreviated
t=s.currentdatabase.server
reg.RegistrationServer = s.currentdatabase.server
Call reg.GetUserInfo(uname, retmailserver, retmailfile)
Set MailDb=New NotesDatabase(retmailserve
set doct=maildb.CreateDocument
Call doct.replaceItemValue("For
Call doct.replaceItemValue("ReA
Call doct.replaceItemValue("App
Call doct.replaceItemValue("Sub
Call doct.replaceItemValue("$Al
Call doct.replaceItemValue("$Al
Call doct.replaceItemValue("$Al
Call doct.replaceItemValue("$Al
Call doct.replaceItemValue("$Al
Dim ndt As NotesDateTime
t=Cstr(Datevalue(Today))+"
Set ndt = New NotesDateTime(t)
Dim ndt1 As NotesDateTime
t=Cstr(Datevalue(Today))+"
Set ndt1 = New NotesDateTime(t)
Call doct.replaceItemValue("STA
Call doct.replaceItemValue("Sta
Call doct.replaceItemValue("End
Call doct.replaceItemValue("Sta
Call doct.replaceItemValue("End
Call doct.replaceItemValue("Cal
Call doct.ComputeWithForm(True,
Call doct.Save(True,True)
cheers,
Tom