Manage Learn to apply best practices and optimize your operations.

Find all databases associated with a template

This tip will provide a list of all databases that use a particular template, along with a count of how many databases were found.

Did you ever want to find all databases that refresh from a particular template? This will provide you with a list of databases that use the template along with a count of how many were found.

This code can be used several different ways. For my purposes, I created a form with the following fields:

ServerName (text, editable)
TemplateName (text, editable)
Number (text, computed, default value Number) 
databases (text, computed, default value databases)

Then I created a button with the following code:

Sub Click(Source As Button)
 
 Dim workspace As New NotesUIWorkspace 
 Dim uidoc As NotesUIDocument
 Set uidoc = workspace.CurrentDocument
 Dim doc As NotesDocument
 Set doc = uidoc.Document
 Dim db As NotesDatabase
 
 Dim strServ As String
 strServ = doc.ServerName(0)
 If strServ = "" Then
  Msgbox "You must fill in the Server you want
 to search on!"
  Call uidoc.GoToField("ServerName")
  Exit Sub
 End If
 Dim dbdir As New NotesDbDirectory(strServ)
 
 Dim strNTF As String
 strNTF = doc.TemplateName(0)
 If strNTF = "" Then
  Msgbox "You must fill in the 
Template name to search for!"
  Call uidoc.GoToField("TemplateName")
  Exit Sub
 End If
 
 Dim cnt As Integer
 cnt = 0
 Set db = dbdir.GetFirstDatabase(DATABASE)
 While Not (db Is Nothing)
  If db.DesignTemplateName = strNTF Then
   doc.databases = db.Title & "   
 FILE: " & db.filepath & Chr(10) & doc.databases(0)
   cnt = cnt + 1
  End If
  Set db = dbdir.GetNextDatabase
 Wend
 
 If doc.databases(0) = "" Then
  doc.databases = "NO MATCH FOUND!!"
 End If
 
 doc.Number = Str(cnt) + " databases found"
End Sub

To use, simply enter a server name and template name, then click the button.

Do you have comments on this tip? Let us know.

This tip was submitted to the SearchDomino.com tip exchange by member Susan Virgilio. Please let others know how useful it is via the rating scale at the end of the tip. Do you have a useful Notes/Domino tip or code to share? Submit it to our bimonthly tip contest and you could win a prize and a spot in our Hall of Fame.

This was last published in September 2005

Dig Deeper on Lotus Notes Domino Coding and Development

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchExchange

SearchContentManagement

Close