Solved

Updating document using the Loop Function - Part II

Posted on 2004-08-13
4
237 Views
Last Modified: 2013-12-18
Hello there.  I am requesting assistance with an Agent.  

This is same concept as the Question titled: "Updating documents using the Loop Function" in which I requested help and received a great answer yesterday.  Now, using the same concept with another agent, I am hitting an error message, as described below.

I am trying to perform a Loop where multiple documents can be updated at one time.

The business side of this application is the tracking of storage boxes in our warehouse.  These boxes contain financial, payment, legal documents.  When a user RETURNS a box to the warehouse, they select the document with that BoxNumber in the database.  Each document has a BoxNumber, and many documents can share the same BoxNumber.  The current status of this document is 'Signed Out'.  When the user presses the button 'Return A Box', this Agent is triggered and runs.  Currently, this Agent changes the status of this document from 'Signed Out' to 'In Storage'.  This field is called 'StatusNow'.  

This same BoxNumber can appear on other documents.  My issue is that other documents that share this BoxNumber are not being updated with the current status.  Currently, an error message is occurring of: 'Notes error: Entry not found in index (and view name)'.  

I have declared all of my variables already.
This agent runs 'On event'.
The fields on my form are (used for this Agent are):
- BoxNumber;
- StatusNow;

What I am attempting to accomplish:  
When the Agent runs, change the first document field of 'StatusNow' from 'Signed Out' to to 'In Storage.'  Go to the next document.  If the BoxNumber of the next document is identical as the BoxNumber of the first document, change the 'StatusNow' field of this next document to 'In Storage'.  Keep repeating until all documents with that identical BoxNumber have the correct status.

Below is my code:
viewkey =  doc.BoxNumber(0)  
Set view = db.GetView("ByBoxNum1")
Call View.Refresh
Set docstatus = view.GetDocumentByKey(viewkey, True)
Set doc = view.GetFirstDocument()
      
'Obtain Box Number of the document updated - if any other documents in the database have this same Box Number, change their status to 'In Storage'

Do While Not (doc Is Nothing)
If doc.BoxNumber(0) = docstatus.BoxNumber(0) Then    
doc.statusnow = "Signed In"
Else
End If      
Call doc.save(True,True)                            
Set doc = view.GetNextDocument(doc)
Loop
Msgbox "All Accounts associated with this Box Number have been updated to Checked In.",48,"Check In Confirmation"      
      
What I do know:
I have run this with the Debug LotusScript on.  I go through successfully the first time and then hit the 'Loop', and return successfully to the Do While statement.  I make it successfully to 'Loop' again, but then I fail.  The error is:  'Notes error: Entry not found in index (and view name)'.  I am confused by the fact that the first document that went through, it's status was changed successfully.  Any next document that tries to go through fails.  What does the Loop not keep going?        

Can you help me out as to why my Loop is failing after I set up the same logic yesterday in another agent?  

Thank you.
0
Comment
Question by:CL_Quality_Assurance
  • 2
4 Comments
 
LVL 24

Accepted Solution

by:
HemanthaKumar earned 500 total points
ID: 11796376
probably the document is falling out of the view after the update .. if this occurs the probability of the loop failing is high.

One way to solve is not to rely on view which fis filtered by statusnow field or any other key fields that makes doc disappear from the view.

~Hemanth
0
 
LVL 5

Expert Comment

by:snocross
ID: 11796421
Maybe you need to add this line;

View.autoupdate = False
0
 

Author Comment

by:CL_Quality_Assurance
ID: 11796625
Oh, that's it HemanthaKumar.
My view is specifically coded to only shows statusnow = 'Signed Out'.  Once that first document is changed, it falls out of the view, therefore, the loop has nothing to reference.

I have removed the view criteria to show all documents.  Now, when I run the agent, everything works as expected.

Wow, the simple things sometime.  Thank you.
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 11797065
yes simple things becomes pain in the ar...
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question