Creating a ToDo using Lotus Script Agent

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. Every button on ToDo form is wroking fine except the “Mark Completed” button. When I click that button only the window is closing and nothing is happening.Can anyone help me.******************************************************************************************************

Sub Initialize

Dim session As New NotesSession

Dim db As NotesDatabase

Dim doc As NotesDocument

Dim maildoc As NotesDocument

Dim bodyitem As NotesRichTextItem

Set db=session.GetDatabase(“”,“WebSiteTraining.nsf”)

Set CurrDoc=session.DocumentContext

Set maildoc=db.CreateDocument

With maildoc

.form = "TaskNotice"	

.Subject=Currdoc.SubjectTX(0)

.Alarms = ""

.Categories = "P"

.DefaultMailSaveOptions = "1"

.From=session.CommonUserName

.Chair=session.CommonUserName

.AltChair=session.CommonUserName

.StorageRequiredNames="1"

.TaskType="2"

.AltRequiredNames=Currdoc.SentTo(0)

.AssignedTo=Currdoc.SentTo(0)

.Recipients=Currdoc.SentTo(0)

.sendTo=Currdoc.SentTo(0)

.CopyTo=Currdoc.CopyTo(0)

.Importance="1"

.DefaultMailSaveOptions="1"

.MailOptions="0"

.CalendarDateTime = Cdat(Currdoc.StartDate(0))

.STARTDATETIME=Cdat(Currdoc.StartDate(0))

.DueDateTime=Cdat(CurrDoc.EndDate(0))

.NoticeType="A"

.OrgConfidential="1"

.MileStone="1"

.DUESTATE = 1

End With

BodyMsg=CurrDoc.MessageTX(0)

Set bodyitem=maildoc.CreateRichTextItem(“Body”)

Call bodyitem.AppendText(BodyMsg)

Call bodyitem.AddNewline(2)

Call maildoc.Send(False)

End Sub

Subject: Creating a ToDo using Lotus Script Agent

Have debugged through the querysave/queryclose event and see why it is not doing what you expect? I bet there is a field that you are not setting that the script expects somewhere.