The script below will help you if you would like to create a URL link through the web browser. It will work for a database whether it is opened on the Notes Server, open on your local machine or disconnected from the network. The example I am using is the database profile doc but could be any link. This tip should help you overcome the @DBName limitation (through the Domino server, it will only return the filepath of the database; for the server it returns a value of ""). I developed it because I like to develop my Notes Web applications locally disconnected from the Domino Server. This also opens up other possibilities (allowing users to use Web based Notes applications disconnected from the server). I am in the process of writing a script that will use any drive by first finding the local drive path, but it will be limited to a Windows based machine (it presently only uses the "C" drive, or whatever drive you specify).
Caveats: A local copy of the database must reside in the same directory structure as Notes Server. For example, if it is located in "C:NotesDataSales," it must be located in the "Sales" directory relative to your Lotus Notes Client data directory. In addition, the local client directory must be located in either "NotesData" or "LotusNotesData;" however, you can modify my code to provide for other installation possibilities.
First you will need to create a Script Library named "String Functions." It is a script Library that I have accumulated several handy functions from other developers (by permission). The one you need hear is "ReplaceSubstring:"
Function ReplaceSubstring (fullString As String, oldString As String, newString As String) As String lenOldString = Len(oldString) position = Instr (fullString, oldString) Do While position > 0 And oldString < > "" fullString = Left(fullString, position -1) & newString & Mid (fullString, position + lenOldString) position = Instr (position + Len(newString), fullString, oldString) Loop ReplaceSubstring = fullString End Function
Save this script Library. Now create an agent called "URLLink", the agent should run "Manually from Agent List", should be shared, and select "Run Once (@Commands may be used)".
Under "Options add the line: Use "String Functions."
Next, add the code:
Dim s As New NotesSession Dim db As NotesDatabase Dim view As NotesView Dim profile As NotesDocument
'I am using a hidden view to track the Database Profile for reasons I do not want to go into here. Set db = s.CurrentDatabase Set view = db.GetView("(Preferences)") Set profile = view.GetDocumentByKey("1", True)
Dim filePath As String filePath = ReplaceSubstring(db.FilePath, "", "/") Dim compare1 As String Dim compare2 As String
'This is where you can change the drive letter for the local machine. compare1 = "c:/lotus/notes/data/" compare2 = "c:/notes/data/" Dim answer1 As Integer Dim answer2 As Integer
'Below is where you set the conditions to match the file path. If you need more, add them below and to the conditional 'statement underneath it.
answer1 = Instr(1, filePath, compare1, 1) answer2 = Instr(1, filePath, compare2, 1)
'The following code tries to catch the local file path and convert it so it will work on a local machine. I will 'go back later and write it so that it works on any file path. Presently on only works on drive listed above. If answer1 > 0 Then filePath = ReplaceSubstring(filePath, compare1, "") End If If answer2 > 0 Then filePath = ReplaceSubstring(filePath, compare2, "") End If
'Below is where you can change the code to reflect whatever URL you wish.
'If an Interest Profile has not been created already, create a new one. If profile Is Nothing Then Print "[/"+ filePath +"/"+"DBProfile?OpenForm]" Else Print "[/"+ filePath +"/(Preferences)/"+ Lcase(profile.universalid)+"?EditDocument]" End If
Now save the agent and call the agent on your URL link. If the database is local, then the URL will point to the "http://localhost" server, if it is on the Notes Server, it will refer back to it.
Use the FileName property instead of FilePath so you won't have to do the Compare1, 2 and the replace Substring.
(Notes Designer Help) Read-only. The full file name of a database, including the extension but excluding the path. Defined in NotesDatabase