Action Button to create New Task

My first attempt in LotusScript-- I have a locally developed Helpdesk App I would like to add a new action to. This action would allow users to create a new task populated with information from the HelpDesk ticket. I would also like a link back to the orginal Helpdesk ticket.

The form name is “Create Request|CR”

The I would like the following fields from the ticket to copy to the new task:

CR_subject > Subject

CR_date > StartDate

CR_description > Body

This is what I have so far- I’m popping the task form, but no information is inherited.

Thanks

Sub Click(Source As Button)

Dim session As New NotesSession

Dim ws As New NotesUIWorkspace

Dim maildb As Notesdatabase

Dim taskuidoc As NotesUIDocument

Dim CRuidoc As NotesUIDocument

Dim taskdoc As NotesDocument

Dim CRdoc As NotesDocument

Dim taskbody As Variant

Dim subject As Variant





Set CRuidoc = ws.CurrentDocument

Set maildb = New NotesDatabase("","")

maildb.OpenMail

Set taskuidoc = ws.ComposeDocument(maildb.Server, maildb.FilePath, "Task")



Set CRdoc = CRuidoc.Document



subject = "Subject"





taskuidoc.fieldappendtext "Body",subject

End Sub

Subject: Action Button to create New Task

I use the button to call an agent (Never have as much code as you do in a button). Make task a response type form.

The agent code for your scenario would be something like:

Dim session As New NotesSession

Dim ws As New NotesUIWorkspace

Dim db As Notesdatabase

Set db = session.CurrentDatabase

Dim uidoc As NotesUIDocument

Set uidoc = ws.CurrentDocument

Dim parentDoc As NotesDocument

Set parentDoc = uidoc.Document

Dim responseDoc As NotesDocument

Set responseDoc = db.CreateDocument

Call responseDoc.MakeResponse( parentDoc )

responseDoc.Form = “Task”

'Set your field values here if needed

responseDoc.CR_Subject=parentDoc.subject(0)

responseDoc.CR_Date=parentDoc.Date(0)

dim rtItem as NotesRichTextItem

Set rtitem = New NotesRichTextItem _

( responseDoc, “CR_Description” )

Call rtitem.AppendText( parentDoc.Body )

Call rtitem.AddNewLine(2)

call rtitem.Appenddoclink (parentdoc)

Call responseDoc.Save( True, True )

Call ws.SetTargetFrame( “main” )

'Put the response document on the Front End

Call ws.EditDocument( True, responseDoc )

Subject: Action Button to create New Task

Are you in the Helpdesk ticket when creating a new Request? If so, your code could be like the following:

Dim Workspace as new NotesUIWorkspace

dim Session as New NotesSession

dim Db as NotesDatabase

dim UIDoc as NotesUIDocument

dim docCR as NotesDocument

dim docTicket as NotesDocument

set Db = Session.CurrentDatabase

set UIDoc = Workspace.CurrentDocument

set docCR = New NotesDocument(Db)

set docTicket = UIDoc.Document

docCR.Form = “CR”

docCR.CR_Subject = docTicket.Subject

docCR.CR_date(0) = docTicket.StartDate(0)

docCR.Description = docTicket.Body

call docCR.Save(True, false, true)

This is on the fly so there is probably a few mistakes around but you get the gist.

Hope this helps,

Katherine

Subject: RE: Action Button to create New Task

I’m in the help desk when I click on the button- but I want the task to be created in the current user mail db.