Friday, May 26, 2006

Show-n-Tell Thursday - Updating FolderReferences

We recently enabled FolderReferences on a database that already contained a lot of documents. According to everything I've read, you can only get FolderReferences for documents added to a folder after the property is enabled, but we needed to get it set for all the existing documents as well. I found a pretty simple way to do it. Just add an action to your folder template and refresh the design of all folders (or add the action to each folder) and run on selected documents.

Here's the code:

Sub Click(Source As Button)
On Error Goto errhand
Dim w as new notesuiworkspace
Dim s As New notessession
Dim db As notesdatabase
Dim v As notesview
Dim uiv as notesuiview
Dim doc As notesdocument
Dim dc As notesdocumentcollection

Set db = s.currentdatabase
Set dc = db.unprocesseddocuments
Set uiv = uiw.currentview
Set v = uiv.view

Set doc = dc.getfirstdocument
While Not doc Is Nothing
Call doc.RemoveFromFolder(v.Name)
Call doc.PutInFolder(v.Name, False)
Set doc = dc.getnextdocument(doc)

Call uiv.deselectall
Call w.ViewRefresh

Exit Sub
Print "Error at line " & Erl & ": " & Error & " for UNID " & doc.universalid
Resume nextDoc
End Sub

This LotusScript was converted to HTML using the ls2html routine,
provided by Julian Robichaux at

Show-n-tell thursday
Show-n-Tell Thursday


Anonymous said...

I am just a notes user and dont know much about programming. Are any step by step instructions available somewhere?

Esther said...

Are you referring to this post:

If you are an end user, there's not much you can do. You need the Designer client in order to add a view and add the buttons to your folder templates. And I somehow doubt, if you are an end user, that your staff admin/developer is going to allow you to change the template anyway. If this is something that you think your entire company can benefit from, bring it up with your corporate developer. The code I posted should make perfect sense to him/her.