A kind of summary document

Is there anyone who can give me a sample to help me understand how:

To create an agent that make a report once pr. month about the number of documents in a database with a specific information in a field.

My database contains quality complaints

I have a field with 3 status (0, 1 and 2)

Once pr. month I have to calculate the last 12 month reports with status 1.

If this number is >=12 then my rating is “black” = bad.

If the number is <12 then I have to calculate the last 6 month reports with status 1.

I this number >=6 then my rating is “red” = danger.

I would like to have this agent to create an email and send a report about this to the quality management group. The best would have been if the agent created a “summary document”, stored this in the database and then sent an email with the report and a link to that summary document.

Subject: A kind of summary document

The jobs your agent must do:

  1. Get the collection of documents to analyze. Since the agent is only run once per month use NotesDatabase.Search to build a document collection rather than using a view (although either approach would work).

  2. Iterate through the your collection and accumulate values for your calculation.

  3. Build an email or a document containing the message that you want based on the data gathered in step 2 and your business logic.

HTH

Subject: RE: A kind of summary document

You can change the selection Formula of the view using lotus script.here is the sample code.

Sub Initialize

'Prompts user for beginning and ending dates

'Changes selection formula to display docs between dates

Dim uiw As New NotesUIWorkspace

Dim uiview As NotesUIView

Dim view As NotesView

Dim formula As String

Dim one As String

Dim two As String

Dim ct As Integer

one = uiw.Prompt(Prompt_OKCANCELEDIT,“Enter the starting date”,

        "Start Date (use format MM/DD/YY)","")

two = uiw.Prompt(Prompt_OKCANCELEDIT,“Enter the ending date”,

        "End Date (use format MM/DD/YY)","")

formula = |SELECT Date > [| & one & |]

         & Date < [| & two & |]|

Set uiview = uiw.CurrentView

Set view = uiview.View

view.SelectionFormula = formula

Call uiw.ViewRebuild

ct = view.EntryCount

Messagebox "The number of docs in this view = " &

          ct,,"Count of docs in view"

End Sub

and here is the article which explains this.

Thanks

Sushant

Subject: RE: A kind of summary document

This seems like overkill. You could just create a view of these documents, categorized by month, most recent first, with totals. Your agent can use a NotesViewNavigator to scan this view and read the totals from the first however many category entries, come up with a status summary (red, black, or colorless) and send this as a one-sentence memo to the quality folks along with a link to the totals view.

Subject: RE: A kind of summary document

Thanks for your input and it seems good as a start for me. However, the 12 month period is “floating” so I need to calculate from now (March 2008) and back to April 2007 for my report. Therefore catagorizing by month is not quite correct.

But, I see your point.