Search DominoPower's 10,675 Lotus-related article archive 
Home
EasyPrint
News details Click here for the RSS feed's XML code. This is not a browser URL.
Articles-only Click here for the RSS feed's XML code. This is not a browser URL.
Twitter Feed Click here for the Twitter feed.
THIS WEEK'S POWERTIP
A Fix for folders and documents
By Mick Moignard

Oh, the perils of putting code in DominoPower articles! People might just try to run the stuff, and then find that it doesn't work.

No sooner had my piece on Folders and Lost Documents appeared on DominoPower (at http://www.DominoPower.com/issues/issue200310/00001122001.html), than I had an email from Peter Reilly who said:

I've pasted the [agent code] into an Agent. The agent is set to run on selected documents. From the All Documents View, I select 6 documents, and then run the agent from the Actions menu. I get the following error: "Document was deleted from this collection". Could you point me to what I might be doing wrong?

The short answer to Peter was nothing. The problem was in my code, not in what he'd done. I'd written it some years back to solve a particular problem, and must never have run into the error. So when I dragged the code out for the article, I just assumed it would work. Dumb, huh?

Here's the fragment of the code that illustrates the problem:

While Not(doc Is Nothing)
If doc.folderreferences(0) <> "" Then
Call doccoll.deletedocument(doc)
End If
Set doc = doccoll.GetNextDocument(doc)
Wend

The 'Document was deleted' message is issued when the GetNextDocument call is made. The GetNextDocument all gets the next document using the argument NotesDocument as a placeholder. So when the code removes a document from the collection, the GetNextDocument fails because the document passed in the argument isn't in the collection, so GetNextDocument has no idea where it is.

There are two solutions to this problem. Here's the first one -- and yes, I have tested this one!

01 Sub Initialize
02 Dim sess As New notessession
03 Dim db As notesdatabase
04 Set db = sess.currentdatabase
05 db.FolderReferencesEnabled = True
06 Dim doccoll As NotesDocumentCollection
07 Dim tempdoc As notesdocument
08 Set doccoll = db.AllDocuments
09
10 Set doc = doccoll.GetFirstDocument
11
12 While Not(doc Is Nothing)
13 If doc.folderreferences(0) <> "" Then 'doc is in at least one folder...
14 Set tempdoc = doc
15 Set doc = doccoll.GetNextDocument(doc)
16 Call doccoll.deletedocument(tempdoc) 'pull it from the collection
17 Else
18 Set doc = doccoll.GetNextDocument(doc)
19 End If
20 Wend
21 Call doccoll.PutAllInFolder("(Inbox)") 'all those that remain in the collection
22 End Sub

You can see that in Line 8 I have Dim'd another NotesDocument object. When I need to remove a document from the collection, I first make a copy of the reference to it to my spare NotesDocument -- that happens in line 14. Then in line 15 I can get the next document, because the current 'doc' is still in the folder. Line 16, I remove the saved document from the folder.


1  ·  2  ·  Next »
Other articles you might like
Home > Strategies > Email Management (60 articles)
   Using the Notes Client with Gmail
   Using the Notes client with Hotmail (or not)
   Is English-only a viable mail management strategy?
Home > Tips & Techniques (95 articles)
   When the debugger won't debug hidden code that isn't hidden
   What to do if the LotusScript debugger won't single-step over code
   Troubleshooting an OpenSuse Notes install
Get Weekly Email Updates
Subscribe to our regular weekly email newsletter. It's packed with tips, reviews, deep analysis, and the latest news.
 
Recent DominoPower Articles
What to look for in a Domino-based document management solution
Understanding Domino.doc end-of-life options
When the debugger won't debug hidden code that isn't hidden
What to do if the LotusScript debugger won't single-step over code
Top 10 ways to launch and build a Lotus consulting practice (with a little help from the Beatles)
Troubleshooting an OpenSuse Notes install
Incident report: denial of service attack against ConnectedPhotographer.com
Latest Lotus Headlines
SnTT - Enabling ALL the bells and whistles!
Tivoli Data protection causes Domino to crash
Fun when running DB2 CLP scripts
Introducing Flippr, the easy way to admin Quickr
DXL and fake security
Using search forms in IBM Workplace Collaborative Learning 2.7
Schmidt, Freed, and Gering on the OVF Toolkit
>> Read all the news
More from the ZATZ journals
Computing Unplugged: Eight steps to successful and reliable home backups
David Gewirtz Online: CNN commentary and analysis
OutlookPower: Can Outlook run when it's not running (and other mysteries)?
-- Advertisement --

PistolStar: Lotus Notes Authentication That Breaks the Status Quo
Password Power's complete integration with the Microsoft Active Directory password enables Notes client access, ends time-consuming Notes ID password recovery and addresses known issues with Notes 8.5:
  • Passwords are encrypted in volatile memory - not stored on user's hard drive
  • Notes roaming capabilities are fully functional - not limited
  • Password checking is honored - no decreased security or failed compliance
  • All Notes ID file copies are synched automatically with Active Directory password - no remembering old passwords or restoring ID files


Learn more about Password Power's powerful, advanced functionality.
-- Advertisement --

Easy Domino Access: Remove Passwords, End Login Prompts, Reduce Password Management
PistolStar's Password Power provides browser-based single sign-on to Lotus Domino, Sametime and Quickr with the enhanced security of the Kerberos or NTLM authentication protocol.

  • Full support available for NTLM authentication protocol in non-Active Directory environments
  • Seamlessly integrate Microsoft Active Directory and the Kerberos authentication protocol
  • Leverage Active Directory password policies to unify Lotus applications


Learn more about Password Power's powerful, advanced functionality.
ZATZ Home  ·  News  ·  Back Issues  ·  Credits/Trademarks ·  Link To Us
Copyright © 1998-2009, ZATZ Publishing. All rights reserved worldwide.
Editor's Login