Notes Error: Entry Not Found in Index (viewname)

I receive the error message - Notes Error: Entry Not Found in Index (viewname) when I attempt to run the following agent:

Sub Initialize

Dim session As New NotesSession

Dim db As NotesDatabase

Dim doc As NotesDocument

Dim rtffield As NotesRichTextItem

Dim ebo As NotesEmbeddedObject

Dim view As NotesView

Set db = session.CurrentDatabase

Set view = db.GetView (“Pdf Attachments”)

Set doc = view.GetFirstDocument

While Not(doc Is Nothing)

afp = doc.FaxOnDemand

afp1 = Cstr(afp(0))

Set rtffield = doc.CreateRichTextItem(“Body”)

Set ebo = rtffield.EmbedObject(EMBED_ATTACHMENT,“”,"c:\RCRA" + afp1 + “.pdf”)

Call doc.save(True,True)

Set doc = view.GetNextDocument(doc)

Wend

End Sub

I have already tried recreating the index, view, and agent with no success. The agent has worked in the past with no problems. Any help would be greatly appreciated. Thanks.

Chris

Subject: Notes Error: Entry Not Found in Index (viewname)

When you save the document with Call doc.Save(True,True) you will force the viewindex to be rebuilt. This will cause the GetNextDocument() to throw out the error “Entry not found in index”, since the current object is out of scope for the viewindex that is held in the view-object.

You can try a couple of things to overcome this problem:

Instead of using GetNextDocument, move the objectpointer to the first document in the view with “GetFirstDocument()” method. If You use this approach - I suggest that You have a viewformula that will not include documents that You have embedded pdf’s in them. Or You will be ending up in a never ending loop.

The next thing You could try is to set the viewproperty “AutoUpdate” to ‘False’ before the loop starts and then set it back to ‘True’, when the loop has finished. This I haven’t tried, but it seems that this should be applicable according to the help documentation.

hth

Subject: Notes Error: Entry Not Found in Index (viewname)

Thanks guys! That did the trick.

Subject: This may or may not work, but try…

Set view = db.GetView (“Pdf Attachments”)Set doc = view.GetFirstDocument

view.AutoUpdate = False

While Not(doc Is Nothing)

afp = doc.FaxOnDemand

afp1 = Cstr(afp(0))

Set rtffield = doc.CreateRichTextItem(“Body”)

Set ebo = rtffield.EmbedObject(EMBED_ATTACHMENT,“”,"c:\RCRA" + afp1 + “.pdf”)

Call doc.save(True,True)

Set doc = view.GetNextDocument(doc)

Wend