Xpage getDatabase - doesn't get the database

Hello

Starting with my first XPages attempt and have run issues.

I have two views and one button. One viewpanel is in the current database, another is in a different database.

The one button should set the same flag across two databases.

If I use

whichDB=database for the current database, my updates work.

If I use getDatabase method with server and fileanme then it doesn’t.

I can of course use database for the current database but I used the getDatabase to see if it was something like an access problem in the external database but it can’t be if

whichDB = database works but the server name and file path do not for the current database.

I have tried

  • hardwiring the server name and path

  • putting !! in front of database name

and I really just do not know why it is not working.

The code for my button is below.

I would really appreciate any guidance!

Thanks in advance

Kathy

<xp:button value=“New Button” id=“button1”>

<xp:eventHandler event=“onclick” submit=“true” refreshMode=“partial”>

xp:this.action<![CDATA[#{javascript:

var docServer = @Name(“[CN]”, Subset(@DbName(), 1));

print(@Name(“CN]”,@Subset(@DbName(),1))) for (v=1;v<3;v++){

var viewPanel=getComponent(“viewPanel” + v );

var whichDB:NotesDatabase

if (v == 1){

whichDB=session.getDatabase(@Name(“CN]”,@Subset(@DbName(),1)), “prod\events.nsf”);

}

else{

whichDB=session.getDatabase(@Name(“CN]”,@Subset(@DbName(),1)), “prod\diary.nsf”);

}

print ("title = "+ whichDB.getTitle())

var docIDs=@Explode(viewPanel.getSelectedIds());

for(i=0 ; i < docIDs.length ; i++){

var docId = docIDs[i];

var doc:NotesDocument = whichDB.getDocumentByID(docId);

			doc.replaceItemValue("Publish", "");

doc.save(true, false)}}}]]></xp:this.action>

</xp:eventHandler>

</xp:button>

Subject: Escape character

Hi,

The backslash character is an escape character in SSJS. If you need a backslash character in a string, you’ll have to escape it. Try to use

“prod\diary.nsf”

Since the target database seems to be on the same server as the one containing your XPage, you can use an empty string as the first parameter of the getDatabase call:

var whichDb:NotesDatabase = session.getDatabase(“”, “prod\diary.nsf”);

Mark

Subject: That was it!

Thank you so much for taking the time to respond.All the examples I had come across did not have folders in the filename so no escape chars examples and I am new to SSJS.

Again much appreciated!