XPages: Saving document in alternate database problem

I have a button in an XPage which is meant to save the current document and then create a new document in another db in which it sets a form field value and also puts the UNID of my current document in a field called ParentUNID and then saves that document also. I am currently testing this in the Notes client

When I click the button nothing happens however. If I create a separate save button for the current doc only that works fine. I suspect I cannot access the other db although I have full rights in the acl and anonymously also.

The javascript that runs on the onclick event is

a standard one from OpenNTF

document.save();

uploadDB=session.getDatabase(null,“FileUploadDB.nsf”);

if (uploadDB.isOpen()){

doc=document.getDocument(); //get current document



rdoc = uploadDB.createDocument();

rdoc.appendItemValue("Form", "Attachment");

rdoc.appendItemValue("ParentUNID",doc.getUniversalID());

rdoc.save();

//note: the redirect to page is only needed until beta 2 where

// we can use the reloadPage()

url=view.getPageName()+"?action=editDocument&documentId="+document.getNoteID();

context.redirectToPage(url);

}

What should I check to resolve this?

Subject: getDatabase problem?

I know there are differences with using getDatabase on a client and web. Is your other database on local? I think that’s what null refers to.

It may also be worth looking at this post by David Leedy http://planetlotus.org/profiles/xpages_70975

I’d strongly recommend adding some kind of error handling in. It will save you a lot of time trying to work out what goes wrong with code. I tend to use OpenLogXPages which can be found in TaskJam. For 8.5.2 you need to use e.toString() to return the error message though, not e.getMessage() - that is no longer a function of the error object. If it’s not getDatabase, error handling will tell you exactly where it is.

Subject: Logging

Tried all sorts of things with the database reference. The help says keep it blank when its the same db but then variables cannot reference it properly it seems. I have tried hard coding name of server and database path , using replica id etc. NotesSession is not goign to work with a web session so a simple getdatabase is not too effective.

Regarding logging - found taskJam and it seems quite rich. I customised the scriptlibrary to my DB as according to instructions but need a way of referencing it from the XPage. I have loaded it as a resource in the XPage and placed a display errors field in the XPage but still do not get the actual error as to why the java script fails for my drop down list from a view interrogation with @dbcolumn.

Subject: Re: Logging

OpenLogXPages logs to an OpenLog database - OpenLog is another very useful project also on OpenNTF with logging script libraries for lotusscript, javascript and java. It also allows you to set up notifications of logs, so you can find out as soon as possible that a problem has occurred.

I see what you mean about the Help. When I’ve pulled information from other databases, I’ve used database.getServer() to define the server name, e.g.

var certsDb:NotesDatabase=session.getDatabase(database.getServer(),“certs.nsf”,false);

Subject: Did a different way

Did not resolve this - just saved the document in the same database. So have a solution for my project but if anyone has a script for a save action that will save document in other db would be interested in it