0% found this document useful (0 votes)
211 views2 pages

Create Task

This function creates a Notes task (todo) document by: 1. Accepting parameters like assigned user, subject, start date, due date, body, and category. 2. Populating fields of a new Notes task document with the parameter values. 3. Saving the document and optionally opening it for editing. 4. Returning a success or failure value.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
211 views2 pages

Create Task

This function creates a Notes task (todo) document by: 1. Accepting parameters like assigned user, subject, start date, due date, body, and category. 2. Populating fields of a new Notes task document with the parameter values. 3. Saving the document and optionally opening it for editing. 4. Returning a success or failure value.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

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 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"
.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
.Chair = assignedTo
.CopyTo = copyto
.Categories = categoryText
.TaskType = "1"
.tmpOwnerHW = "1"
.tmpNoActionBar = "1"
.NoticeType = ""
.~_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 li
ke to edit this task now?", 36, GetTitle())) = 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

You might also like