XPages: @DbName () removes slashes from the database file path

I use @DbName () to get the name and path of the notes database file. Unfortunately, the file path and name are returned as a single line without a slash. For example, if the path to the file is "Dir1 / Dir2 / dbname.nsf", it is returned as "Dir1Dir2dbname.nsf". Is there any way to get the path to the file with slashes?

+4
source share
3 answers

The function call @DBName () should be used as an array of a list. The following example details how to use and what result 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 did not get these results, update your question with a sample code.

Another thing to check is to translate "\" as an escape character into your code.

+3
source

I experienced something similar, and the fix really had to use the following to make sure the backslashes are escaped (instead of being interpreted as an escape character):

 escape(database.getFilePath()) 
+2
source

Do you put this in a computed field or use it in some kind of formula? here is another way.

database.getFilePath ()

This should give you Dir / dbname

+1
source

Source: https://habr.com/ru/post/1480972/


All Articles