user1358852
user1358852

Reputation:

XPages: @DbName() removes slashes from the database filepath

I'm using @DbName() to get the name and filepath of a notes database. Unfortunately the filepath and name are returned as one string without slashes. For example, if the filepath is "Dir1/Dir2/dbname.nsf", it is returned as "Dir1Dir2dbname.nsf". Is there any way of getting the filepath with the slashes included?

Upvotes: 4

Views: 1542

Answers (3)

Per Henrik Lausten
Per Henrik Lausten

Reputation: 21709

I have experienced something similar and the fix was indeed to use the following to make sure that backslashes are escaped (instead of being interpreted as an escape character):

escape(database.getFilePath())

Upvotes: 2

Simon O'Doherty
Simon O'Doherty

Reputation: 9359

The @DBName() function call should be used as a list array. The following sample details how to use and what output you get.

CODE

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
    <xp:table><xp:tr>
    <xp:td>
        <xp:label value="Field 1 (@DbName as a string) " id="label1">
        </xp:label>
    </xp:td><xp:td>
        <xp:text escape="true" id="computedField1" value="#{javascript:return @DbName();}">
        </xp:text>
    </xp:td>
    </xp:tr><xp:tr>
    <xp:td>
        <xp:label value="Field 2 (@DbName used as list)" id="label2">
        </xp:label>
    </xp:td><xp:td>
        <xp:text escape="true" id="computedField2">
        <xp:this.value><![CDATA[#{javascript:var database = @Subset(@DbName(), -1);
            var server = @Name("[CN]", @Subset(@DbName(), 1));
            return database + " on " + server
            }]]></xp:this.value>
        </xp:text>
    </xp:td></xp:tr>
    </xp:table>
</xp:view>

OUTPUT

Field 1 (@DbName as a string)   CN=testserver/O=testorg,subdir\Test.nsf
Field 2 (@DbName used as list)  subdir\Test.nsf on testserver

If you are not getting these results, please update your question with sample code.

The other thing to check is if the "\" is being translated as an escape character in your code.

Upvotes: 3

Patrick Sawyer
Patrick Sawyer

Reputation: 1382

Are you putting this in a computed field or are you using this in some formula? here is another way.

database.getFilePath()

That should give you Dir/dbname

Upvotes: 1

Related Questions