Creating a ToDo Task with Lotus Script

I have the following code, which I found in the Sandbox and have made some modifications to. It works great as it creates the ToDo Task but when I view the actual task that was created I do not see the participants. I have this same problem with creating an Invitation from Lotus Script - participants are not visible. I have reviewed the TODO form through designed to ensure that I was setting all the correct fields in order to get the participants to display, but I have no luck. Any suggestions would be appreciated.

CODE:


Function CreateTask(assignedTo As String, subject As String, startDate As String, dueDate As String, body As String, import As Variant, linkto As notesdocument, categoryText As String) As Integer

%REM

'This function creates a Notes TASK (ToDo) in the mail database

Parameters:

  1. assignedTo - Type String. A person name.

  2. subject - Type String. The task subject.

  3. startDate - Type Variant. The starting date of the task.

  4. dueDate - Type Variant. The completion date of the task.

  5. body - Type String. The contents of the task body.

  6. import - Type Variant. The importance of the task. 1=High, 2=Medium, 3=Low

  7. linkto - Type NotesDocument. Used to create a doclink.

  8. categoryText - Type String. The task category.

Example of Usage:

 subject = "Custom Subject"

 completion by " & doc.DueDate(0)

startdate = Today

duedate = Cdat(doc.DueDate(0))

assignedTo = doc.Champion(0)



 body = "Custom Body" & Chr(10)

cat = "SIU"

–>> Call SendTask(assignedTo, subject, startdate, duedate, body, “1”, doc, cat)

%END REM

Dim session As New NotesSession

Dim ws As New NotesUIWorkspace

Dim rtitem As NotesRichTextItem

Dim todoDoc As NotesDocument

Dim maildb As New NotesDatabase( "", "" )

Call maildb.OpenMail

Set todoDoc = New NotesDocument(maildb)



'Setup error handling

On Error Goto ErrorHandler



'Populate task fields 

With todoDoc

	.Form = "Task"

	.Alarms = "1"

	.Subject = subject

	.StartDate = Cdat(startdate & " 12:01:00 PM")

	.DueDate = Cdat(duedate & " 12:01:00 PM")

	.DueDateTime = Cdat(duedate & " 12:01:00 PM")

	.CalendarDateTime = Cdat(startdate & " 12:01:00 PM")

	.Importance = import

	.AssignedTo = assignedto

	.tmpRequired = assignedto

	.Chair = session.UserName

	.CopyTo = ""

	.Categories = categoryText 

	If assignedto = "" Then

		.TaskType = "1"

	Else

		.TaskType = "2"

	End If

	.tmpAction = "6"

	.tmpOwnerHW = "1"

’ .tmpNoActionBar = “1”

	.tmpNoActionBar = ""

	'.NoticeType = ""

	.DUESTATE = 1

	.PostedDate = Date

	.~_ViewIcon = 8

End With



'Handle the rich text Body field and doclink

Set rtItem = todoDoc.CreateRichTextItem("Body")

Call rtItem.AddNewLine(2)

Call rtItem.AppendText(body)

If Not( linkto Is Nothing) Then

	Call rtItem.AddNewLine(2)

	Call rtItem.AppendText("Click link to open document -->")

	Call rtItem.AppendDocLink(linkto, "Click link to open document")

End If



'Save the Task (ToDo) document

Call todoDoc.ComputeWithForm(False, False)

Call todoDoc.save(True, False)



'If (Msgbox("A new task was created and saved." & Chr(10) & "Would you like to edit this task now?", 36, "Action Item") = 6) Then

	'Display the newly created task in edit mode		

'	Call ws.EditDocument(True, todoDoc)

'End If



'Return a success

SendTask=True



Exit Function

ErrorHandler:

Print ( "Error " & Str$(Err) & ": " & Error$ )

Resume TheEnd

TheEnd:

'Return a failure

SendTask = False

End Function

Subject: Creating a ToDo Task with Lotus Script

The name value (for AssignedTo and eventually Participants) should be a Variant containing a string or an array of strings.

Subject: RE: Creating a ToDo Task with Lotus Script

The AssignedTo field is actually being set with the script, however when you actually open the ToDo from the mail file the ‘Participants’ section to the right of the form does not show. I reviewed the Hide/Whens on the actual form to ensure that all the fields were set, which they are but still the ‘Participants’ section is not visible.