I created an agent that goes through each document in a view and sets the status to Archive to documents that isn’t a “New Vendor Setup” document and then sends an email to each employee.
After I ran the agent, the documents were correctly modified and an email was sent to the first employee in the 1st Categorized column but then I receive a “Subscript out of range” error (through debugger, the Set entry = nav.GetNextCategory(entry) is where the error is). Is this because I’m updating all the documents before I send out the emails? If so, is there a way I can get around that? Below is the code that I’m using to modify the documents.
While Not (doc Is Nothing)
If doc.Status(0) <> “Archive” Then
If (doc.VendorInfo(0) <> “New Vendor Setup” Or doc.VendorInfo(0) = “”)Then
Call doc.ReplaceItemValue(“Status”, “Archive”)
Call doc.Save(True, False)
End If
End If
Set doc = view.GetNextDocument(doc)
Wend
Additionally, I added an If-Else block to check if entry.ColumnValues(0) is not blank. Any suggestions would be appreciated.
Subject: GetNextCategory Issue
Here is how I normally get around this sort of thing:
dim nextdoc as NotesDocument
While Not (doc Is Nothing)
set nextdoc = view.GetNextDocument(doc)
If doc.Status(0) <> “Archive” Then
If (doc.VendorInfo(0) <> “New Vendor Setup” Or doc.VendorInfo(0) = “”)Then
Call doc.ReplaceItemValue(“Status”, “Archive”)
Call doc.Save(True, False)
End If
End If
Set doc = nextdoc
Wend
Subject: RE: GetNextCategory Issue
Steven, thank you for your suggestion. After I added your suggested codes, I still received the “Subscript out of range” error. I’m beginning to wonder if it has to do with the entries. Anyways, I included the entry loop (without all the mailing codes) and hoping that someone can shed a light on this issue.
Set view = db.GetView(“TestExpDocs”)
Set nav = view.CreateViewNav
Set entry = nav.GetFirst
While Not entry Is Nothing
If entry.ColumnValues(0) <> “” Then
Set mailDoc = db.CreateDocument
Email information
End If
Set entry = nav.GetNextCategory(entry) **the error is found here
Wend
Subject: RE: GetNextCategory Issue
are you really, really, really sure that’s the error line? Because that’s an array error message, and nothing on that line is an array.
Subject: RE: GetNextCategory Issue
Andre, yes I am sure that the agent stopped on that line. If I could do a screenshot in here, I would. If it’s not really the error, then what could it be? I do notice that after I receive the error and run the agent again, I get all the emails as expected. Any suggestions? Thank you for taking your time to help me, Andre.
Subject: RE: GetNextCategory Issue
Is it possible that there’s a document that doesn’t have a VendorInfo field? Pulling at straws here.
Subject: RE: GetNextCategory Issue
Thank you, Mort, for your suggestion.
Subject: GetNextCategory Issue – SOLVED
Thank you, Steven, Andre, and Mort for your help and suggeestions. Thanks to my co-worker, I was able to figure out the problem and to fix it.
It had nothing to do with the VendorInfo field (Mort’s suggestion) or the setting the documents to Archive. According to my co-worker, the problem was that I was setting the document BEFORE gathering a list of authors that will be used to send the emails. How I got this to work is to move the Forall loop (to get the authors) to be before the setting the documents.
Again, thank you everyone for taking your time to help me out.