Manage Learn to apply best practices and optimize your operations.

LS to retrieve all views from any database

LS to retrieve all views from any database

Used in a script library, this script grabs the servers and the domain name, lists all the servers in a selection, then lists all the databases on the selected server, lists all the views in the selected database, and opens the view. It helps me as an admin to avoid unnecessary browsing... I guess you could just put it into a shared action as well. I named the script library "getDatabaseViews", and in the declaration of a shared action added the Use "getDatabaseViews"...then just called it from Click: user = getDatabaseViews. It's easier to just put everything into one shared action, though...with the same result...

Sub Click(Source As Button)
      Dim workspace As New NotesUIWorkspace
      Dim Session As New NotesSession
      Dim addressDB As New NotesDatabase("", "names.nsf")
      Dim uidoc As NotesUIDocument
      Dim db As NotesDatabase
      Dim addressView As NotesView
      Dim addressDoc As NotesDocument
      Dim message As String
      Dim getDatabase As Variant
      Dim getView As Variant
      Dim getServer As Variant
      Dim collectionDatabases() As String
      Dim collectionViews() As String
      Dim collectionServers() As String
      Dim fileName() As String
      Dim d As Integer
      Dim v As Integer
      Dim temp As String
      Dim inx As Integer
      Dim tempDB As String

      Set addressView = addressDB.GetView("Connections")
      Set addressDoc = addressView.GetFirstDocument
      inx  = 0
      While Not(addressDoc Is Nothing)
            Redim Preserve collectionServers(0 To inx)
            collectionServers(inx) = addressDoc.Destination(0)
            inx = inx + 1
            Set addressDoc = addressView.GetNextDocument(addressDoc)
      Wend
      'end server retrieval and selection

      'get current user location
      tempLocation = Session.GetEnvironmentString( "Location", True )
      currentLocation = Strleft(tempLocation, ",")

      'use the current location document to retrieve the domain name
      Set addressView = addressDB.GetView("Locations")
      Set addressDoc = addressView.GetFirstDocument
      While Not (addressDoc Is Nothing)
            If addressDoc.Name(0) = currentLocation Then
                  domainName = addressDoc.Domain(0)
            End If
            Set addressDoc = addressView.GetNextDocument(addressDoc)
      Wend

      'prompt for the server to grab the database list from
      getServer = workspace.Prompt( PROMPT_OKCANCELLIST, "Listed are all
servers in the " & domainName & " domain." , "Select server to open:",
collectionServers(1), collectionServers)
      If getServer = "" Then
            Messagebox "Action cancelled by user", 0 + 16, "Cancelled"
            Exit Sub
      End If

      'take that server selected above and list all the databases it
contains, except for those in the mail subdirectory
      'and allow for selection of desired database
      Dim dbdir As New NotesDbDirectory(Cstr(getServer))
      Set db = dbdir.GetFirstDatabase(DATABASE)
      Set uidoc = workspace.currentDocument
      d = 0
      While Not(db Is Nothing)
            d = d + 1
            Redim Preserve collectionDatabases( 1 To d )
            collectionDatabases(d) = db.Title
            Redim Preserve fileName( 1 To d )
            fileName(d) = db.FileName
            Set db = dbdir.GetNextDatabase
            Print d & " Databases Retrieved"
      Wend
      getDatabase = workspace.Prompt( PROMPT_OKCANCELLIST, "List of
databases", "Select database views to retreive:", collectionDatabases(1),
collectionDatabases )
      'end database retrieval and selection
      If getDatabase = "" Then
            Messagebox "Action cancelled by user", 0 + 16, "Cancelled"
            Exit Sub
      End If

      'now take the server and database arguments and list the views of the
desired database
      'allow for selection of the desired view
      Set db = dbdir.GetFirstDatabase(DATABASE)
      v = 0
      inx = 0
      While v <= d
            temp = Cstr(db.FilePath)
            If Instr(temp, "mail") Then
                  Set db = dbdir.GetNextDatabase
            Else
                  If db.Title = Cstr(getDatabase) Then
                        Set db = Session.getdatabase(Cstr(getServer),
Cstr(db.FilePath))
                        tempDB = db.FilePath
                        Forall c In db.Views
                              inx = inx + 1
                              Redim Preserve collectionViews( 1 To inx )
                              collectionViews(inx) = c.name
                              Print inx & " Views Retrieved"
                        End Forall
                        v = d + 1
                        getView = workspace.Prompt( PROMPT_OKCANCELLIST,
"List of views", "Select view to open:", collectionViews(1),
collectionViews )
                        Print ""
                        If getView = "" Then
                              Messagebox "Action cancelled by user", 0 +
16, "Cancelled"
                              Exit Sub
                        End If
                  End If
                  If v <= d Then
                        v = v + 1
                        Set db = dbdir.GetNextDatabase
                  End If
            End If
      Wend
      'end view selection and retireval

      'if there is some error, tell the user, if not, then open the view
      If tempDB = "" Then
            Messagebox "Error", 0 + 16, "Error somewhere"
            Print ""
            Exit Sub
      Else
            Call workspace.OpenDatabase(  Cstr(getServer), tempDB,
Cstr(getView))
      End If
      'end of alg...

End Sub

Dig Deeper on Lotus Notes Domino Administration Tools

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

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

SearchContentManagement

Close