Tuesday, 10 April 2007

Dynamic setting of urls in Domino

With a Domino .nsf file, occasionally you need to move a database from one server to another, but how do you keep your links intact when the new server has a new URL?

I have come up with 3 ways that I make use of that all return the same result. One is in formula language, one is in lotusscript and one in javascript.

Formula Language

[code]"https://" + @GetHTTPHeader("Host") + "/" + @ReplaceSubstring(@Subset(@DbName; -1); " " : ""; "+" : "/") + "/"[/code]

Lotusscript

[code]Dim Session As NotesSession
Dim dbase As NotesDatabase
Dim path As String
Set Session=New NotesSession
Set dbase=session.currentdatabase
path = "https://" & Strrightback(Strleftback(dbase.HttpURL, "/"), "/") & "/" & dbase.FilePath & "/"[/code]