I am using the Java API, but any other language would probably suffice for an answer.
I am developing an application to add a to do item to a user’s to do list, but I can’t figure out how to add a Document to the Uncompleted to do list View. Any ideas on how to add a Document to a View? I can successfully save a document using save(), but this saves it to the Drafts View in email.
This is a very poorly documented part of Notes and have requested on several instances that Loyus/IBM open up the Calendar and Scheduling with LS Classes for these sort of things. I spent a bunch of hours struggling trying to drive the To Do list from an application that I was building and finally gave up. That was a few years ago and there might be some better helps out there now but I have not attempted to search them out.
Here’s a bit of code I use to create a calendar entry in a shared mail file - you can adapt it to create a to-do (task)
Dim session As New NotesSession
Dim workspace As New NotesUIWorkspace
Dim maildb As notesdatabase
Dim entry As notesdocument
Dim db As notesdatabase
Dim uidoc As notesUIdocument
Dim doc As notesdocument
Dim CView As NotesView
Dim CDoc As NotesDocument
Dim CPath As String
Set db = session.currentdatabase
Set uidoc = workspace.currentdocument
Set doc = uidoc.document
Set CView = db.GetView("Config")
Set Cdoc = CView.GetDocumentByKey(2)
CPath = CDoc.C_Values(0)
Set maildb = session.getdatabase("Saturn/SITAUK", CPath)
Set entry = maildb.createdocument
Dim startitem As NotesItem
Dim enditem As NotesItem
Dim starttime As NotesDateTime
Dim endtime As NotesDateTime
Set startitem = doc.GetFirstItem("CseStart")
Set enditem = doc.GetFirstItem("CseEnd")
Set starttime = startitem.DateTimeValue
Set endtime = enditem.DateTimeValue
entry.form = "Appointment"
entry.appointmenttype = "3"
entry.subject = doc.title(0)
entry.location = doc.locations(0)
entry.RequiredAttendees = doc.students
entry.EnterSendTo = doc.students
Set uidoc = workspace.editdocument(True, entry)
Call uidoc.FieldSetText("StartDate", starttime.DateOnly)
Call uidoc.FieldSetText("EndDate", endtime.DateOnly)
Call uidoc.FieldSetText("StartTime", "09:00:00")
Call uidoc.FieldSetText("EndTime", "17:00:00")
Call uidoc.refresh
Call entry.ComputeWithForm(True, False)
I’ve got the path stored in a config doc in the Config view, but you can either compute it or hard code it.
A quick glance indicates the code provided by james is the best place for you to start. You could look at the script, libraries, classes and everything in the mail template, but I agree with the other poster, it is very difficult to find a way through it. Instead, I would recommend saving calendar entries and looking at the properties. You can surmise the meaning of the values much quicker than reading the code, in this case.