< Back

Document Subject: @WebDbName is not available in XPages
Hint Short Cut: Add this to your code & documentation to help you find this page.
http://#Xpage-WebDbName or http://A555F9/nn.nsf/ByAlias/Xpage-WebDbName

@WebDbName is not a javascript function available to Xpages. There is a simple formula you can use instead.




This formula is from Notes Ninjas.

It is from the Golden Rule 3 of Lotus Notes Ninjas.

The formula has been changed by adding brackets to @DbName and using commas instead of semicolons.

@Implode(@Explode(@Subset(@DbName(),-1), @Char(92)),"/")

 

There is another solution from Michael Gollmick.

http://blog.gollmick.de/mgoblog.nsf/dx/WebDBName_in_XPages.htm

Code:

/** *****************************************************************
* 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 20090119
****************************************************************** */
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;
}
/* ******************************************************************
* END @WebDBName
****************************************************************** */