function getWebDBName() {
var arg=@Trim(arguments[0]);
var webDBName="";
if (typeof arg!="undefined"){
webDBName=@ReplaceSubstring(arg,"\\","/");
return webDBName;
}
var dbPath=@DbName()[1];
webDBName=@ReplaceSubstring(dbPath,"\\","/");
return webDBName;
}
The following are the ways in which u can use the above function
getWebDBName("a\\b/c\\d.nsf"); //will return a/b/c/d.nsf
getWebDBName(database); //will return @WebDBName;
getWebDBName(); //will return @WebDBName;
getWebDBName(db:NotesDatabase); // will return @WebDBName of the db object being passed
Hope this helps :)
/**
ReplyDelete* provides functionality of the function with same name from @Formula
*
* @return the name of the current database in a websave format
* @author Michael Gollmick
* @version 1.2
* @date 20090127
*/
function @WebDbName() {
try {
if (typeof this.name === 'undefined') {
var path = database.getFilePath();
var re = new RegExp("\\\\", "g");
path = path.replace(re, "/");
var arr = path.split("/");
for (var a = 0; a < arr.length; a++) {
arr[a] = escape(arr[a]);
}
this.name = arr.join("/");
}
} catch (e) {
}
return this.name;
}
I'll throw in mine as well :)
ReplyDeletefunction getWebPath( db:NotesDatabase ){
try {
db = db || database;
return '/' + db.getFilePath().replace( /\\/g, '/' );
} catch( e ){
/*Debug.logException( e );*/
}
}
Thank you for sharing these functions. They are really great. :)
ReplyDeletewhy not use: session.evaluate("@WebDbName")
ReplyDelete...or get it from getHttpURL()
ReplyDelete@Thomas: session.evaluate("@WebDbName") works great,
ReplyDeletewhere as session.getHttpURL()for a database in my local hard drive returns,
http://SystemName.MyDomainName.local?OpenServer.
I would prefer an empty string or the name localhost to be returned here. I smell complications with getHttpURL() :)
Thanks a lot for these suggestions.