Solved

Updating document using the Loop Function - Part II

Posted on 2004-08-13
4
233 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
Comment Utility
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
Comment Utility
Maybe you need to add this line;

View.autoupdate = False
0
 

Author Comment

by:CL_Quality_Assurance
Comment Utility
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
Comment Utility
yes simple things becomes pain in the ar...
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

  In today’s Arena we can’t imagine our lives without Internet as we are highly used to of it. If we consider our life style just for only 2 min we found that face to face communication is swapped by e-communication.  Every Where from Works place to…
Article by: Rob
Notes 8.5 Archiving Steps and Tips This article covers setting up a Notes archive, and helps understand some of the menu choices making setting up and maintaining a Notes archive file easier.
This video discusses moving either the default database or any database to a new volume.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now