Get the template name from a database

Here is a quick LotusScript tip on how to get the name of the template that is used for a specific database. The NotesDatabase Class has a method to determine the template name. But this only works for a template file itself ( template.ntf ) As far a I could find out, there is no method to grab the template name for a database.

I found out theat the name is stored in the NotesDatabase icon. The icon can be accessed as any other Notes document. From Release 6 on there is a new class called NotesNoteCollection class . The NotesNoteCollection class represents a collection of Domino design and data elements in a database.

I did a quick debug to find the proper place to look for the template name value. Well, here is the code.

Function getTemplate( db As NotesDatabase ) As String

	Dim template As String, aux As String
	Dim nc As NotesNoteCollection
	Dim icon As notesdocument
	Dim noteid As String

	getTemplate = ""
	Set nc = db.CreateNoteCollection( False )
	nc.SelectIcon = True
	Call nc.BuildCollection

	Set icon = db.GetDocumentByID( nc.GetFirstNoteId )

	If Not icon Is Nothing Then
		getTemplate = icon.Parentdatabase.DesigntemplateName
	End If

End Function

To test the code, put the funktion together with the following code into an action button in a view of your “sandbox” database

Sub Click(Source As Button)
	Dim s As New NotesSession
	Dim db As NotesDatabase
	Set db = s.currentdatabase
	Msgbox getTemplate ( db )
End Sub

YTRIA – FREE License Keys for the Summer!

Are you still using the Limited Version of YTRIA tools? Did you ever want to use the Full Version? Now you can (for a limited-time) and at no cost! If you ever wanted to try Ytria tools, then here’s your chance…Take advantage of our limited-time summer offer and use any (or all) of our tools starting right now! This is a limited-time offer, between July 18, 2006 and August 18, 2006 so enjoy our tools and start saving time!

YTRIA - FREE License Keys for the Summer!