A bit of code that can make your TeamStudio Configurator reports a bit easier to work with...
Category Software Development
I had a request from an internal customer today involving scanning a particular Notes database for the occurrence of some specified strings. This is related to a request from Legal, so of course it needs to be accurate and the results need to be easy to use. After listening to what she was trying to do on her own, I suggested that it would be best if I did the scans for her, using the TeamStudio Configurator tool. So far, so good.
The only issue I have with the output from the tool is that the Configurator report only shows you the string being scanned for along with the document title and Notes ID. But unless you're a Notes geek, that Notes ID means virtually nothing to you as an end user. In those cases, the users try to find the document title in the database. Not pretty...
I wrote the following quick and dirty code to put behind an action button that I add to the Configurator report form design. It's meant to be used under the condition that you have a separate report document for each string match. Feel free to steal or appropriate as needed...
Sub Click(Source As Button)
Dim session As New NotesSession
Dim ws As New NotesUIWorkspace
Dim dbThis As NotesDatabase
Dim dbScanned As NotesDatabase
Dim uidocThis As NotesUIDocument
Dim docThis As NotesDocument
Dim docScanned As NotesDocument
'Stores the primary extracted strings needed to get the document that matched the scan
Dim strScannedDBServer As String
Dim strScannedDBPath As String
Dim strScannedNoteID As String
Dim intStart As Integer
Dim intEnd As Integer
Set dbThis = session.CurrentDatabase
Set uidocThis = ws.CurrentDocument
Set docThis = uidocThis.Document
'This grabs the canonical server name stored in the frptDatabase field of the Configurator Report document
intStart = Instr(1, docThis.frptDatabase(0), "CN=")
intEnd = Instr(intStart, docThis.frptDatabase(0), "(")
strScannedDBServer = Mid$(docThis.frptDatabase(0), intStart, intEnd - intStart)
'The file path follows the canonical server name, so grab that here.
intStart = intEnd + 1
intEnd = Len(docThis.frptDatabase(0))
strScannedDBPath = Mid$(docThis.frptDatabase(0), intStart, intEnd - intStart)
'Finally, the NoteID of the scanned document is stored at the end of the frptNoteTitle field of the Configurator Report document
intEnd = Len(docThis.frptNoteTitle(0))
intStart = intEnd - 8
strScannedNoteID = Mid$(docThis.frptNoteTitle(0), intStart, 8)
'You have everything you need to get the scanned database and document now.
Set dbScanned = session.GetDatabase(strScannedDbServer, strScannedDbPath)
Set docScanned = dbScanned.GetDocumentByID(strScannedNoteID)
If Not (docScanned Is Nothing) Then
Call ws.EditDocument(False, docScanned, True)
Else
Messagebox "NoteID " + strScannedNoteID + " not found"
End If
End Sub
EDIT 10/13/2008 - John Kingsley from TeamStudio suggested making the following change in the code so it would work for both server-based and local databases... Thanks, John!
This post was fabulous. I had to make some changes to it because they don't let me near any servers here, so everything is local. Try this
instead of
'This grabs the canonical server name stored in the frptDatabase field of the Configurator Report document
intStart = Instr(1, docThis.frptDatabase(0), "CN=")
intEnd = Instr(intStart, docThis.frptDatabase(0), "(")
strScannedDBServer = Mid$(docThis.frptDatabase(0), intStart, intEnd - intStart)
try this.
'This grabs the canonical server name stored in the frptDatabase field of the Configurator Report document
If Instr( 1, docThis.frptDatabase( 0 ), "CN=" ) Then
intStart = Instr(1, docThis.frptDatabase(0), "CN=")
intEnd = Instr(intStart, docThis.frptDatabase(0), "(")
strScannedDBServer = Mid$(docThis.frptDatabase(0), intStart, intEnd - intStart)
Else
intStart = Instr(1, docThis.frptDatabase(0), "Local")
intEnd = Instr(intStart, docThis.frptDatabase(0), "(")
strScannedDBServer = ""
End If
I had a request from an internal customer today involving scanning a particular Notes database for the occurrence of some specified strings. This is related to a request from Legal, so of course it needs to be accurate and the results need to be easy to use. After listening to what she was trying to do on her own, I suggested that it would be best if I did the scans for her, using the TeamStudio Configurator tool. So far, so good.
The only issue I have with the output from the tool is that the Configurator report only shows you the string being scanned for along with the document title and Notes ID. But unless you're a Notes geek, that Notes ID means virtually nothing to you as an end user. In those cases, the users try to find the document title in the database. Not pretty...
I wrote the following quick and dirty code to put behind an action button that I add to the Configurator report form design. It's meant to be used under the condition that you have a separate report document for each string match. Feel free to steal or appropriate as needed...
Sub Click(Source As Button)
Dim session As New NotesSession
Dim ws As New NotesUIWorkspace
Dim dbThis As NotesDatabase
Dim dbScanned As NotesDatabase
Dim uidocThis As NotesUIDocument
Dim docThis As NotesDocument
Dim docScanned As NotesDocument
'Stores the primary extracted strings needed to get the document that matched the scan
Dim strScannedDBServer As String
Dim strScannedDBPath As String
Dim strScannedNoteID As String
Dim intStart As Integer
Dim intEnd As Integer
Set dbThis = session.CurrentDatabase
Set uidocThis = ws.CurrentDocument
Set docThis = uidocThis.Document
'This grabs the canonical server name stored in the frptDatabase field of the Configurator Report document
intStart = Instr(1, docThis.frptDatabase(0), "CN=")
intEnd = Instr(intStart, docThis.frptDatabase(0), "(")
strScannedDBServer = Mid$(docThis.frptDatabase(0), intStart, intEnd - intStart)
'The file path follows the canonical server name, so grab that here.
intStart = intEnd + 1
intEnd = Len(docThis.frptDatabase(0))
strScannedDBPath = Mid$(docThis.frptDatabase(0), intStart, intEnd - intStart)
'Finally, the NoteID of the scanned document is stored at the end of the frptNoteTitle field of the Configurator Report document
intEnd = Len(docThis.frptNoteTitle(0))
intStart = intEnd - 8
strScannedNoteID = Mid$(docThis.frptNoteTitle(0), intStart, 8)
'You have everything you need to get the scanned database and document now.
Set dbScanned = session.GetDatabase(strScannedDbServer, strScannedDbPath)
Set docScanned = dbScanned.GetDocumentByID(strScannedNoteID)
If Not (docScanned Is Nothing) Then
Call ws.EditDocument(False, docScanned, True)
Else
Messagebox "NoteID " + strScannedNoteID + " not found"
End If
End Sub
EDIT 10/13/2008 - John Kingsley from TeamStudio suggested making the following change in the code so it would work for both server-based and local databases... Thanks, John!
This post was fabulous. I had to make some changes to it because they don't let me near any servers here, so everything is local. Try this
instead of
'This grabs the canonical server name stored in the frptDatabase field of the Configurator Report document
intStart = Instr(1, docThis.frptDatabase(0), "CN=")
intEnd = Instr(intStart, docThis.frptDatabase(0), "(")
strScannedDBServer = Mid$(docThis.frptDatabase(0), intStart, intEnd - intStart)
try this.
'This grabs the canonical server name stored in the frptDatabase field of the Configurator Report document
If Instr( 1, docThis.frptDatabase( 0 ), "CN=" ) Then
intStart = Instr(1, docThis.frptDatabase(0), "CN=")
intEnd = Instr(intStart, docThis.frptDatabase(0), "(")
strScannedDBServer = Mid$(docThis.frptDatabase(0), intStart, intEnd - intStart)
Else
intStart = Instr(1, docThis.frptDatabase(0), "Local")
intEnd = Instr(intStart, docThis.frptDatabase(0), "(")
strScannedDBServer = ""
End If



Comments
John
Posted by John Coolidge At 10:16:59 On 16/04/2008 | - Website - |
Stay tuned...
Rock
(VP of Products, Teamstudio)
Posted by Rock At 09:15:49 On 20/04/2008 | - Website - |