GetDocumentbyKey not finding newly created documents, use Db.Search instead?

I have a form that creates documents in the background–a time entry form where people enter time for various jobs on various dates–the time is saved in a separate document based on the job and month. I use one form to create various documents in the background.

I don’t want more than one time sheet for each job for each time period so I was using the GetDocumentByKey to see if the time document already exists, then either create a new time sheet, or append the new data to the existing time sheet.

However, it seems that GetDocumentByKey sometimes did not find newly-created time sheets and would create a new one (as if the view did not have time to refresh). So I changed to using Db.Search (each time sheet document has a field with a string indicating User, Job and Time Period, so the search formula is fairly simple.

But I am concerned about performance as the Db grows. I can limit the number of documents in a view by “expiring” time sheets over 6 months old, so the GetDocumentByKey would only have a subset of documents to search through, whereas the Db.Search will have to search all documents every time.

Am I wrong in thinking that the GetDocumentByKey may miss newly-created documents (maybe created within the past few minutes?). Perhaps something else in my formula is wrong? Most of the time the GetDocumentbyKey worked correctly, but a few times it didn’t.

Subject: GetDocumentbyKey not finding newly created documents, use Db.Search instead?

Hi,

did you refresh the view?

Most of the time, it does automatically, but to be shure, I would appreciate

notesView.Refresh

Autoupdate wont trigger if you do not get a new reference on the view.

Greetings,

Martin

Subject: GetDocumentbyKey not finding newly created documents, use Db.Search instead?

Have you tried using Call view.Refresh

before your search?

Subject: Thanks. I will try the NotesView.Refresh

Subject: RE: GetDocumentbyKey not finding newly created documents, use Db.Search instead?

The problem is that, the way it works now, I might have to do a lot of NotesView.Refresh calls…

So I may have to figure out a different solution…such as storing the DocID of any found or newly created documents.

Subject: RE: GetDocumentbyKey not finding newly created documents, use Db.Search instead?

Hi Chris,

I’m having the same problem … worked fine before upgrading to Domino 7 !

I have the view.refresh in my code and still having the problem. I’m even having the problem with db.search !

If you fins someting, please post-it here as i will also do if i find more info

Stephan

Subject: RE: GetDocumentbyKey not finding newly created documents, use Db.Search instead?

Hi. i have a very similar problem, but with me, it only fails in a couple entries. i am getting the data from a sql database, to run a loop, that creates and modifies documents.Here’s the creepy thing. if i move the lines in my SQL database, so the ones that give me problems are at the end of the query… it works!!

Please post any solutions on this.

Subject: GetDocumentbyKey not finding newly created documents, use Db.Search instead?

Make sure prior to your view.getdocumentbykey, call the view.refresh to make sure you get all documents.