mariahelm.com
personal website

mariahelm.com

SNTT: Find Templates/Find databases using a template

July 5th, 2007 . by maria

Our shop has always been pretty small. (OK, so there was only one Notes dev before I came along.) So, we were taking a huge step forward a few years ago when we set up a dev server. The problem is, we didn’t take the time to make sure that every database had a template on the new dev server. We just sortof added them as needed. Then, a little while later, we came up with naming conventions for the templates. But, anything created before the naming conventions still has the old name. As a result, it can be pretty difficult to determine if the database you need to work on already has a template on the dev server or not. And if you’re wrong, then when you go to refresh the design, you’ll get an error saying two templates of the same name were found. To make all this easier for myself, I wrote a “button tool” that will find a template for me. This code can be put behind a button in a rich text field named Body on any document, or in an email. (Or you can modify it for your uses.)

Sub Click(Source As Button)
Dim db As notesdatabase
Dim templatenames (1000) As String
Dim counter As Integer
Dim myserver As String
Dim mytemname As String
Dim uidoc As NotesUIDocument
Dim NewList As String
Set ws = New NotesUIWorkspace
Set uidoc=ws.CurrentDocument
myserver = Inputbox$(”What server?”)
Dim dbdir As New notesdbdirectory(myserver)
mytemname = Inputbox$(”What template name?”)
Set db = dbdir.getfirstdatabase(TEMPLATE)
counter = 0
NewList = “New”
While Not(db Is Nothing)
counter = counter + 1
If db.TemplateName=mytemname Then
templatenames(counter) = db.TemplateName & ” – ” & db.FilePath
NewList = “;” & templatenames(counter)
uidoc.FieldAppendText(”Body”),NewList
End If
Set db = dbdir.getnextdatabase
Wend
Call uidoc.refresh
Messagebox(”done”)
End Sub

Leave a Reply

Name

Mail (never published)

Website