I have a database that aggregates a number of document summaries into reports.
There is a shared action that creates the report.
The articles that the report is created from use RTItems to allow for formatting.
All this appears to work fine except for one minor glitch. The last document in the collection does not get put in the report. I know the looping structure sees the document because I get the client list and article title in the report. Those text items are appended right before the RTItem is.
The code is below. Any help is appreciated.
Thanks,
Shawn
Sub Click(Source As Button)
' CREATE SESSION VARIABLES
Dim session As New NotesSession
Dim ws As New NotesUIWorkspace
Dim database As NotesDatabase
Dim documentCollection As NotesDocumentCollection
Dim billSummary As NotesDocument
Dim clientReport As NotesDocument
Dim reportBody As NotesRichTextItem
Dim summaryBody As NotesRichTextItem
Dim richStyle As NotesRichTextStyle
Dim clientField As Variant
' Dim requestedClient As String
' Dim client As String
Dim count As Integer
' SET INITIAL VALUES
Set database = session.CurrentDatabase
count = 1 ' INITIALIZE THE INTEGER
Set documentCollection = database.AllDocuments
Set clientReport = New NotesDocument(database)
Set reportBody = New NotesRichTextItem(clientReport, "fieReportBody")
Set richStyle = session.CreateRichTextStyle
' SET THE DOCUMENT FORM
Call clientReport.ReplaceItemValue( "Form", "frmReportSummary")
' GET THE FIRST DOCUMENT
Set billSummary = documentCollection.GetFirstDocument
' COUNT STARTS AT 0
While(count <= documentCollection.Count)
If billSummary.Form(0) = "frmBillSummary" Then
' Get the summary text
Set summaryBody = billSummary.GetFirstItem("fieBillSummary")
Set clientField = billSummary.GetFirstItem("fieClient")
Forall summaryClient In clientField.Values
reportbody.AppendText(summaryClient & ",")
End Forall
reportBody.AddNewline(1)
' Create and Use Bold Style
richStyle.Bold = True
Call reportBody.AppendStyle(richStyle)
' BUILD THE LINK TO THE BILL SUMMARY
' Call reportBody.AppendDocLink(billSummary, "Bill Summary","link")
Call reportBody.AppendDocLink(billSummary, "Bill Summary",billSummary.fieSummaryType(0) & billSummary.fieBillID(0))
reportBody.AddNewline(2)
' APPEND THE REPORT BODY TO THE SUMMARY
Call reportBody.AppendRTItem(summaryBody)
' ADDED TO ENSURE FINAL RTItem was appended
If count = documentCollection.Count Then
Sleep 2
End If
reportBody.AddNewline(2)
' Turn off Bold Style
richStyle.Bold = False
Call reportBody.AppendStyle(richStyle)
reportBody.AddNewline(2)
End If
Set billSummary = documentCollection.GetNextDocument(billSummary)
count = count + 1
Wend
' SAVE THE REPORT AND OPEN IT FOR VIEWING
' Call clientReport.Save(True, False)
Call ws.EditDocument(False,clientReport,,,,)
End Sub