GetAllDocumentsByKey giving intermittent errors

I’ve got a most ususual problem.

I have a report, run on demand by the users (on the client). Inputs to the report are a start date, end date and mailing group (list of names). The report takes a list of names and sorts them. Then, for each name, it get a collection of all documents for that name from a hidden view. It loops through all the collected documents and totals up time spent in the period. Repeats for each name.

Randomly, as far as I can tell, partway through the report, no more collections are returned. Instead I get zero as the collection total.

Report Example:

           ...

RICHARD B.

 54501     Design      6.00       6.75

 54554     Analysis    6.75     24.75

 ...

 53418     Design     2.25        2.25

                                         ---------

                                          40.00

ROBERTA C.

 53893     Analysis     2.00     16.00

 ...

 54692     Analysis     0.25      0.25

                                         ---------

                                          38.50

SMITA L.

                                         ---------

                                         0.00

SUE F.

                                         ---------

                                         0.00

SUSAN D

                                         ---------

                                         0.00

SUZANNE O.

                                         ---------

                                         0.00

TOM H.

                                         ---------

                                         0.00



                                         ---------

Total Time: 434.60


I’ve been to isolate the problem to this code:

WriteReport:

 For a = 0 To Ubound(nameflag)		

	

 'get all docs for that person

 Set coll = view.GetAllDocumentsByKey( Ucase(nameflag(a)), False )                        <<<<<---------



 Call buildbody.AppendText( Ucase(nameflag(a)) )

 Call buildbody.AddNewLine(1)

Partway through the report, it simply stops returning the documents. The documents are there, I can see them in the hidden view used for lookups.

Just before creating this post, I can the same report (same date range, same team) twice in the span of five minutes. The first result you see above. The second time I ran the report, it returned complete, correct results.

The server is running Release 8.0.2FP1.

I have the Release 8.0.2FP1 CCH1 client on my desktop.

I’ve deliberately converted the input names to uppercase and ensured that the view lists names in uppercase.

I’m at my wits end as to why the results are different. Could it be a server issue? Network connection issues?

Subject: two possibilities

without seeing all your code, it’s not possible to diagnose, but you can try two possible solutions.

1.) Are you destroying the collection object at the end if each loop? You should do that, and for good luck, add view.Refresh

2.) Try view.GetAllEntriesByKey instead (using notesViewEntryCollection) since the matching seems to be more adaptable.

HTH

Subject: RE: GetAllDocumentsByKey giving intermittent errors

You should use “True” as parameter to GetAllDocumentsByKey, otherwise you can get a lot of strange results.Set coll = view.GetAllDocumentsByKey( Ucase(nameflag(a)), True )

You can try with view.AutoUpdate = False in the beginning of the script to avoid eventual changes in the view content while the script is running.

When this error happens and you try to get document by a (hardcoded?) key which you know got result earlier in the same execution, do you get the result for the previously working key?

Set coll = view.GetAllDocumentsByKey( Ucase(nameflag(a)), True )

if coll.count=0 then

Set coll2 = view.GetAllDocumentsByKey(“this_key_worked_fine”, True )

if coll2.count=0 then msgbox “Old key doesn’t work any more”

end if

Does it work correctly if you make a local replica/copy of the database? Just to make sure that other users’ actions does not interfier with the documents in the view.

/Andrei

http://www.stwidget.com