Subject: RE: Agent - appending value to report form
I’ve added some remarks in your code in this color, but there are more things you need to do. I see at least one serious error here that I told you about in my last message and you did not correct, so it seems you are not “getting it”. I think perhaps you do not understand LotusScript well enough to do this project. It might be best to find someone local who can help you.
… query$ = workspace.Prompt (PROMPT_OKCANCELLIST,“Select a Date”, “Select one Employee Meeting Date from below list.”, result, result)
… Set dc = db.Search(query$,dateTime,0)
A few things here:
If you don’t want a start date, you can say Nothing here instead of dateTime. Nothing is faster.
You are using the Search method, which requires a macro formula as input, but the user’s input is not a macro formula, just a date.
The Search method is not very efficient, especially if there are many documents in the database. If ou have a view sorted by date, GetAllDocumentsByKey will very quickly return the set of documents you need.
Set doc = dc.GetFirstDocument
Set docReport = db.CreateDocument()
You are trying to use the variable doc for two different things. You cannot use it for these two different things. You need one variable to be “the current document” that you’re examining, and another variable to store the lines of your report. Do not modify “the current document” doc, because you’re just going to throw that value away when you get the next document.
Dim docNext as NotesDocument
For j = 1 To dc.Count
'Set doc = dc.GetNthDocument(j%)
If dc.count >0 j = 1 Then
Because of the For loop above, you never get here unless dc.Count > 0.
I think, anyway, that you intended to test whether j=1.
doc.Form ="MNFR"
docReport.EmpMeetDate = doc.EmpMeetDate
docReport.Department = doc.Department
docReport.FdQuestion = doc.FdQuestion
docReport.Answer = doc.Answer
docReport.FdQuestion1= doc.FdQuestion1
docReport.Answer1= doc.Answer1
docReport.FdQuestion2= doc.FdQuestion2
docReport.Answer2= doc.Answer2
docReport.FdQuestion3 = doc.FdQuestion3
docReport.Answer3= doc.Answer3
Else
docReport.Answer=docReport.Answer(0) & Chr(13) & doc.Answer(0)
docReport.Answer1=docReport.Answer1(0) & Chr(13) & doc.Answer1(0)
docReport.Answer2=docReport.Answer2(0) & Chr(13) & doc.Answer2(0)
docReport.Answer3=docReport.Answer3(0) & Chr(13) & doc.Answer3(0)
End If
Set docNext = dc.GetNextDocument(doc)
Delete doc
Set doc = docNext
Next
docReport.Form ="MNFR"
Set mailDoc = New NotesDocument(db)
Set rtitem = New NotesRichTextItem (maildoc, "Body")
Call rtitem.AddNewLine(1)
Call rtitem.appendtext ("Please review Management Feedback Report: "+doc.EmpMeetDate(0))
Call rtitem.AddNewLine(2)
success = docReport.RenderToRTItem( rtitem )
Please think about what happens here if dc.Count = 0. There is not a report to review. Do you want to send an email that says, “Please review this report” and then there is no report? Or do you want to tell the user who is running this agent, and ask them to choose a different date? It might be that the design of your application is such that if the data is on the list to select, there is always at least one matching document. But I can’t tell that for sure from this code.
mailDoc.Form = "Memo"
mailDoc.Subject = "THIS IS A TEST"
mailDoc.SendTo = session.commeruser
Since there is no such property as commeruser, and since you declared session, this tells me that this is not your actual code. That’s annoying. I’ve been wasting my time reviewing code which is not the same code you are using. Is it really easier for you to retype the whole thing rather than copy and paste?
Call mailDoc.Save( True, True )
It is not necessary to save the document before sending. If you want to save a copy, fine.
Call mailDoc.send(False)