Solved

Updating document using the Loop Function - Part II

Posted on 2004-08-13
4
238 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
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.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

739 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