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)
nextDoc:
Set doc = dc.getnextdocument(doc)
Wend

Call uiv.deselectall
Call w.ViewRefresh

Exit Sub
errhand:
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 nsftools.com.


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

2 comments:

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: https://www-10.lotus.com/ldd/nd6forum.nsf/ShowMyTopicsAllFlatweb/cff6f8fc38daec2d852571c5006f99ff?OpenDocument

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.