«

»

Find “WhichFolders” via Lotusscript

Follow up to my prior post where Denny commented that he wants the @WhichFolders available in Lotusscript. Well, back in March 2008, Bob Balaban blogged about a routine to find what folder a document is in. He blogged a code snippet that was written in C#. An alternative or two, and the timing of the various methods were blogged by Steve McDonagh, so check that out.

Here is my little snippet of the same basic idea as Bob’s, but in Lotusscript. The v.IsFolder bit is a little slow. And obviously, the more folders you have the longer this will take. @WhichFolders is much faster, but doesn’t work outside of view columns!

Dim ses As New NotesSession Dim db As NotesDatabase Dim myViews As Variant Dim myFolders As Variant Set db = ses.CurrentDatabase Dim doccol As NotesDocumentCollection Dim doc As NotesDocument Set doccol = db.UnprocessedDocuments Set doc = doccol.GetFirstDocument() myViews = db.Views Dim viewnav As NotesViewNavigator While Not (doc Is Nothing) ForAll v In myViews If v.IsFolder Then v.AutoUpdate = False Set viewnav = v.CreateViewNavFrom(doc) If viewnav.Count > 0 Then MessageBox v.name End If End If End ForAll Set doc = doccol.Getnextdocument(doc) Wend


ls2html was brought to you by nsftools.com

  • http://www.lotusguru.com Kevin Pettitt

    Nice one Kathy. Any idea about performance on a big (20,000+ docs) mail with 100+ folders?

    Oh, and in case anyone else decides to test using Evaluate({@WhichFolders}, doc), don’t bother. It no workie Emoticon.

  • http://www.jamiemagee.com Jamie Magee

    notesdocument.FolderReferences comes to mind, but I see in Bob’s linked post above he points out some downsides to it. The performance may not be any slower than your technique, and for the same reasons, but yours will work for older docs already in the db…. cool! I didn’t know about the CreateViewFromNav trick. Nice!

    @Kevin – it’s probably not the # of docs, but the number of folders that will impact performance, especially on a Notes Client to server execution of this code. GetView first checks for a case sensitive match on the Name property (NOT the alias!!), then a case sensitive match on the Alias, then a case-INsensitive on the Name, then case-INsensitive on the Alias. So if you use Alias with incorrect case, it will work, but take up to four times longer than the fast way.

  • http://www.videorolls.com/watch/LotusScript-Intro-Ls01-Hello-world LotusScript-Intro

    Thank you for making the things with Lotus a bit easier to understand. I am still quite at a loss as far as this issue, but try to learn as much as possible, have found a couple of educational videos and your article was also of good help Emoticon

  • http://www.pirates-of-caribbean-4.com pirates of caribbean 4 movie

    Here is my little snippet of the same basic idea as Bob’s, but in Lotusscript. The v.IsFolder bit is a little slow. And obviously, the more folders you have the longer this will take. @WhichFolders is much faster, but doesn’t work outside of view columns!

  • http://null Greg

    Nice piece of coding. I was able to use your code for what I really wanted to do, count how many documents were in each folder.

    Just incase someone wants to try this out v.toplevelentryCount will yield that number.

    MessageBox v.name & “–>” &cstr(v.toplevelentryCount) or write to a file

    The code only works in UI. Whenever I attempt to schedule the agent to run it times itself out. That’s what we’ll call a feature. I’m declaring success.

  • vasya

    very slow performance