XPages getDocumentByKey query

I’m trying to use the notesView.getDocumentByKey server-side javascript function, matching against two sorted columns.

The help says I need to pass a java.util.Vector, but my knowledge is limited. Whatever I put in I get the error "Exception occurred calling method NotesView.getDocumentByKey(Array, boolean) null.

I’ve checked my code and it is definitely passing values into the getDocumentByKey function. My code is:

var liveView:NotesView = database.getView(“liveCallsByClientContract”);

var key = compositeData.ClientName;

var keyArr:java.util.Vector = @Explode(key, “~”);

var liveDoc:NotesDocument = liveView.getDocumentByKey(keyArr);

if (liveDoc == null) {

return key;

} else {

return liveDoc.getItemValueInteger("OpenCallsThreshold");

}

compositeData.ClientName is e.g. “Intec Systems Limited~INTEC HOLIDAYS 2009”

I’ve tried passing a vector, an array, just the @Explode itself, all throw the error. Using getDocumentByKey against a single column works fine though.

Has anyone got this working successfully and can point me in the right direction?

Thanks

Paul

Subject: 2nd argument?

Just an idea: have you tried passing the 2nd argument, i.e. “exactmatch = TRUE/FALSE”?

Subject: Re 2nd Argument

Hi Lothar

Yes, I tried with and without the second argument. The copy of the code I took was when I tried without, just to confirm it was definitely the first parameter the code was objecting to.

Paul

Subject: Pass the parameter as a vector

Hi Paul

For getDocumentByKey function, the parameter should be a vector. For this case,

var keyArr= @Explode(key,“~”);//or use split

var keyV=new java.util.Vector();

keyV.addElement(keyArr[0]);

keyV.addElement(keyArr[1]);

var liveDoc:NotesDocument = liveView.getDocumentByKey(keyV,true);

Good luck!

Jis

Subject: Thanks, that works