5 pts.
 Creating a Group Task (todo) using LS.
I need to create a Group Todo from a Lotus Domino database that I'm developing. The Todo will be created with information from a document in this database. What are the fields/items that are necessary to do this? The Domino Version is 6.5.3 and I would like to do this in LS. Thanks

Software/Hardware used:
ASKED: February 9, 2006  1:40 PM
UPDATED: February 16, 2006  4:44 PM

Answer Wiki:
Here is a piece of LS code I use to create the ToDo, technically a "Task", from an action button directly in my mail file. It populates fields from the selected document and creates the ToDo in my mail file. Be sure to set the correct mail file for the user.... Hope it helps... Sub Click(Source As Button) Dim nsession As New NotesSession Dim ws As New NotesUIWorkspace Dim ndoc As NotesDocument Dim uidoc As NotesUIDocument Dim ncollection As NotesDocumentCollection Dim nitem As NotesItem Dim tfld1 As Variant Dim tfld2 As String ' Get the selected document in the current view Set ncollection = nsession.currentdatabase.unprocesseddocuments ' Get out if we didn't select anything If (ncollection.count = 0) Then Exit Sub Set ndoc = ncollection.getfirstdocument() ' Set up the Items we want populated. tfld1 = ndoc.GetItemValue("Project") tfld2 = Cstr(tfld1(0)) Set uidoc = ws.ComposeDocument( "", "mailfile.nsf", "Task" ) ' Populate the NotesItems. Call uidoc.FieldSetText("DueDate","Today") Call uidoc.FieldSetText("StartDate","Today") Call uidoc.FieldSetText("Categories", tfld2) End Sub
Last Wiki Answer Submitted:  February 9, 2006  2:46 pm  by  Maggs   0 pts.
All Answer Wiki Contributors:  Maggs   0 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

I have a database where customer complaint documents can be created by sales staff and assigned to any one in the organisation. The person creating the complaint document fills in various details e.g. type of complaint, customer who made the complaint, person complaint will be assigned to, rich text area for general description of complaint etc.
When the document is saved, a Group To-Do is generated with the document creator as “owner” and the person assigned the complaint the to-do recipient. This person is sent a to-do item which contains details of the complaint in the main body of the message. Here is the code I use:

Sub AssignGroup
On Error Goto ProcessError

Dim CallBody As Variant
Dim unid As String
Set datetime = New NotesDateTime( “” )

‘Need to save document first to be able to access rich text item
‘Call uidoc.Save

Assignee = doc.Assignee
If Assignee(0) = “” Then Exit Sub
Set AssigneeNm = New NotesName(Assignee(0))

‘Instantiate the object variables for the maildoc note that we will create and its Body field
Set maildb = New NotesDatabase(“”,”")
Call maildb.OpenMail
Set maildoc = New NotesDocument(maildb)

Set rtitem = New NotesRichTextItem(maildoc, “Body”)
Set richStyle1 = s.CreateRichTextStyle
Set richStyle2 = s.CreateRichTextStyle
richStyle1.FontSize = 9
richStyle1.Bold = False
richStyle1.NotesColor = COLOR_DARK_BLUE
richStyle2.FontSize = 9
richStyle2.Bold = True
richStyle2.NotesColor = COLOR_DARK_RED

Caller = doc.Caller
ComplaintNo = doc.ComplaintNo
CallPerson = doc.CallPerson
CallDate = doc.CallDate
CompanyName = doc.CompanyName
SiteName = doc.SiteName
‘Set CallBody = doc.GetFirstItem(“CallBody”)
TaskType = “2″ ‘= Group To-Do

‘Specific error trapping for mail send
On Error Goto ErrorSending

‘Generate a Group To-Do Task document
maildoc.Form = “Task”
maildoc.TaskType = TaskType
‘Initialise form fields
‘success = maildoc.ComputeWithForm( False, True )
‘If Not success Then Exit Sub

maildoc.Subject=”Complaint No. ” + ComplaintNo(0) + ” : ” + Format$(CallDate(0), “ddd dd-mmm-yyyy”) +_
” : ” + CompanyName(0) + ” / ” + SiteName(0)
maildoc.Chair = s.UserName
maildoc.AltChair = s.UserName
maildoc.ApptUNID = maildoc.UniversalID
maildoc.AssignedTo = AssigneeNm.Abbreviated
maildoc.AssignState = 2
maildoc.SendTo = AssigneeNm.Canonical
maildoc.CopyTo = “”

maildoc.Importance = “1″ ‘= High
maildoc.Categories = “KAD”
maildoc.Alarms = “”
maildoc.DueDate = “”
maildoc.DueState = 1
maildoc.StartDate = “”
maildoc.MailFirstPass = “1″
‘maildoc.MailOptions = “1″
maildoc.NoticeType = “I”
maildoc.Repeats = “”
maildoc.SequenceNum = 1
‘These 2 fields control button hide-when formulas
maildoc.tmpNoActionBar = “”
maildoc.tmpOwnerHW = “0″
‘Use replaceitemvalue for fields which are also NotesDocument methods
Call maildoc.ReplaceItemValue(“_ViewIcon”, 133)

Call maildoc.ReplaceItemValue(“Encrypt”, “”)
maildoc.DefaultMailSaveOptions = Evaluate(“@Text(@MailSavePreference)”, maildoc)
Call maildoc.ReplaceItemValue(“Sign”, Evaluate(“@Text(@MailSignPreference)”, maildoc) )
maildoc.SMTPKeepNotesItems = “1″
maildoc.OrgConfidential = “”
maildoc.Principal = s.UserName
maildoc.Topic = maildoc.Subject
maildoc.WebCategory = “”
maildoc.WebDateTimeInit = “1″

‘Prepare rich text body
Call rtitem.AppendStyle(richStyle1)
Call rtitem.AppendText(“Complaint raised by : “)
Call rtitem.AppendStyle(richStyle2)
Call rtitem.AppendText(CallPerson(0))
Call rtitem.AddNewLine(1)

Call rtitem.AppendStyle(richStyle1)
Call rtitem.AppendText(“Complaint date : “)
Call rtitem.AppendStyle(richStyle2)
Call rtitem.AppendText(Format$(CallDate(0), “ddd dd-mmm-yyyy”))
Call rtitem.AddNewLine(2)

‘If CallBody.Type = RICHTEXT Then
‘Call rtitem.AppendStyle(richStyle1)
‘Call rtitem.AppendText(“Complaint details : “)
‘Call rtitem.AddNewLine(1)
‘richStyle2.FontSize = 9
‘richStyle2.Bold = False
‘richStyle2.NotesColor = COLOR_DARK_CYAN
‘Call rtitem.AppendStyle(richStyle2)
‘Call rtitem.AppendRTItem(CallBody)
‘Call rtitem.AddNewLine(2)
‘End If

richStyle2.FontSize = 9
richStyle2.Bold = False
richStyle2.NotesColor = COLOR_DARK_MAGENTA
Call rtitem.AppendStyle(richStyle2)
Call rtitem.AppendText(“Click the doclink below to view the Customer Complaint Note “)
Call rtitem.AddNewLine(2)

‘Put a doclink in the Body field
Call rtitem.AppendDocLink(doc, “DocLink to Complaint Note”)

‘Open prepared document
‘Call w.EditDocument(True, maildoc)

‘Remove temporary fields generated by computewithform method
‘Call maildoc.RemoveItem(“tmpOwner”)

‘Send to assignee
Call maildoc.Send (False)

‘Prepare owner’s copy
maildoc.From = s.UserName
maildoc.SendTo = “”
maildoc.tmpNoActionBar = “”
maildoc.tmpOwnerHW = “1″
Call maildoc.ReplaceItemValue(“_ViewIcon”, 168)
Call maildoc.RemoveItem(“Topic”)
Call maildoc.RemoveItem(“MailOptions”)
Call maildoc.RemoveItem(“NoticeType”)
maildoc.Recipients = AssigneeNm.Canonical

‘Save owners copy
Call maildoc.Save (True, False)

‘Retain send information as audit trail
Call doc.ReplaceItemValue(“AssigneeLast”, doc.Assignee)
Call datetime.SetNow
Call doc.ReplaceItemValue(“AssigneeDate”, datetime)
Call doc.ReplaceItemValue(“AssigneeSentBy”, CurrentUser)

‘Display a message telling the user that mail has been sent and to whom
Messagebox “A Group To-Do item has been assigned to ” + AssigneeNm.Common + ” for Complaint No. ” & ComplaintNo(0), 0 + 64, “Customer Complaint”

Exit Sub
ErrorSending:
‘Messagebox “FYI: ” & Recipient & ” could not be notified via email at this time.”, 0 + 64, “Customer Complaint”
Msgbox “Error (” & Cstr(Err) & ” ) -> ” & Error$(Err),16,”AssignGroup”
Exit Sub
ProcessError:
Msgbox “Error (” & Cstr(Err) & ” ) -> ” & Error$(Err),16,”AssignGroup”
Exit Sub
End Sub

 0 pts.

 

Sorry, this is in addition to my previous reply. I accidentally sent it before I was able to tidy up my cut&paste code. Here is the tidied up code:
Notes:
1. Assume that where an object not declared it was declared globally elsewhere e.g. richstyle1.
2. The original document containing the complaint info is object “doc”
3. doc.Assignee holds the person the to-do will be sent to and is a full hierarchical name selected from Domino directory.

Sub AssignGroup
On Error Goto ProcessError

Dim CallBody As Variant

Set s = New NotesSession
Set datetime = New NotesDateTime( “” )

Assignee = doc.Assignee
If Assignee(0) = “” Then Exit Sub
Set AssigneeNm = New NotesName(Assignee(0))

‘Instantiate the object variables for the maildoc note that we will create and its Body field
Set maildb = New NotesDatabase(“”,”")
Call maildb.OpenMail
Set maildoc = New NotesDocument(maildb)

Set rtitem = New NotesRichTextItem(maildoc, “Body”)
Set richStyle1 = s.CreateRichTextStyle
Set richStyle2 = s.CreateRichTextStyle
richStyle1.FontSize = 9
richStyle1.Bold = False
richStyle1.NotesColor = COLOR_DARK_BLUE
richStyle2.FontSize = 9
richStyle2.Bold = True
richStyle2.NotesColor = COLOR_DARK_RED

Caller = doc.Caller
ComplaintNo = doc.ComplaintNo
CallPerson = doc.CallPerson
CallDate = doc.CallDate
CompanyName = doc.CompanyName
SiteName = doc.SiteName

TaskType = “2″ ‘= Group To-Do

‘Specific error trapping for mail send
On Error Goto ErrorSending

‘Generate a Group To-Do Task document
maildoc.Form = “Task”
maildoc.TaskType = TaskType
‘Initialise form fields

maildoc.Subject=”Complaint No. ” + ComplaintNo(0) + ” : ” + Format$(CallDate(0), “ddd dd-mmm-yyyy”) +_
” : ” + CompanyName(0) + ” / ” + SiteName(0)
maildoc.Chair = s.UserName
maildoc.AltChair = s.UserName
maildoc.ApptUNID = maildoc.UniversalID
maildoc.AssignedTo = AssigneeNm.Abbreviated
maildoc.AssignState = 2
maildoc.SendTo = AssigneeNm.Canonical
maildoc.CopyTo = “”

maildoc.Importance = “1″ ‘= High
maildoc.Categories = “CRM”
maildoc.Alarms = “”
maildoc.DueDate = “”
maildoc.DueState = 1
maildoc.StartDate = “”
maildoc.MailFirstPass = “1″
maildoc.NoticeType = “I”
maildoc.Repeats = “”
maildoc.SequenceNum = 1
‘These 2 fields control button hide-when formulas
maildoc.tmpNoActionBar = “”
maildoc.tmpOwnerHW = “0″
‘Use replaceitemvalue for fields which are also NotesDocument methods
Call maildoc.ReplaceItemValue(“_ViewIcon”, 133)

Call maildoc.ReplaceItemValue(“Encrypt”, “”)
maildoc.DefaultMailSaveOptions = Evaluate(“@Text(@MailSavePreference)”, maildoc)
Call maildoc.ReplaceItemValue(“Sign”, Evaluate(“@Text(@MailSignPreference)”, maildoc) )
maildoc.SMTPKeepNotesItems = “1″
maildoc.OrgConfidential = “”
maildoc.Principal = s.UserName
maildoc.Topic = maildoc.Subject
maildoc.WebCategory = “”
maildoc.WebDateTimeInit = “1″

‘Prepare rich text body
Call rtitem.AppendStyle(richStyle1)
Call rtitem.AppendText(“Complaint raised by : “)
Call rtitem.AppendStyle(richStyle2)
Call rtitem.AppendText(CallPerson(0))
Call rtitem.AddNewLine(1)

Call rtitem.AppendStyle(richStyle1)
Call rtitem.AppendText(“Complaint date : “)
Call rtitem.AppendStyle(richStyle2)
Call rtitem.AppendText(Format$(CallDate(0), “ddd dd-mmm-yyyy”))
Call rtitem.AddNewLine(2)

richStyle2.FontSize = 9
richStyle2.Bold = False
richStyle2.NotesColor = COLOR_DARK_MAGENTA
Call rtitem.AppendStyle(richStyle2)
Call rtitem.AppendText(“Click the doclink below to view the Customer Complaint Note “)
Call rtitem.AddNewLine(2)

‘Put a doclink in the Body field
Call rtitem.AppendDocLink(doc, “DocLink to Complaint Note”)

‘Send to assignee
Call maildoc.Send (False)

‘Prepare owner’s copy
maildoc.From = s.UserName
maildoc.SendTo = “”
maildoc.tmpNoActionBar = “”
maildoc.tmpOwnerHW = “1″
Call maildoc.ReplaceItemValue(“_ViewIcon”, 168)
Call maildoc.RemoveItem(“Topic”)
Call maildoc.RemoveItem(“MailOptions”)
Call maildoc.RemoveItem(“NoticeType”)
maildoc.Recipients = AssigneeNm.Canonical

‘Save owners copy
Call maildoc.Save (True, False)

‘Retain send info in original document as audit trail
Call doc.ReplaceItemValue(“AssigneeLast”, doc.Assignee)
Call datetime.SetNow
Call doc.ReplaceItemValue(“AssigneeDate”, datetime)
Call doc.ReplaceItemValue(“AssigneeSentBy”, s.UserName)

‘Display a message telling the user that mail has been sent and to whom
Messagebox “A Group To-Do item has been assigned to ” + AssigneeNm.Common + ” for Complaint No. ” & ComplaintNo(0), 0 + 64, “Customer Complaint”

Exit Sub

ErrorSending:
Msgbox “Error (” & Cstr(Err) & ” ) -> ” & Error$(Err),16,”AssignGroup”
Exit Sub
ProcessError:
Msgbox “Error (” & Cstr(Err) & ” ) -> ” & Error$(Err),16,”AssignGroup”
Exit Sub
End Sub

 0 pts.