I have a problem using getdocumentbykey in ssjs in xPages. I’m trying to use it on the afterpageload event (orbeforepageload), to set an application scope variable. It never finds the relevant doc.
It works if I write the same in a lotusscript agent, so I don’t know whether it’s to do with the event I’m using it in or the way I’m using the methods.
The code is:
var n:NotesName = session.createName(@UserName());
var nab:NotesDatabase = session.getDatabase(session.getServerName(), “names.nsf”);
var v:NotesView = nab.getView(“($Users)”);
var nn:String = n.getCommon();
var doc:NotesDocument = v.getDocumentByKey(nn);
applicationScope.put(“mf”, doc.getItemValue(“MailFile”))
The error is that doc is nothing on setting the application scope, so it’s not finding the doc. It’s definitely there and as I say I can use the view to look up the doc using s.commonusername in lotusscript
Thanks for any help
Dan