Can't Get a Document in XPages via backend

My goal is to have a link on an XPage that opens a specific document by key.

My problem is I’m getting an error when I try to retrieve the document. I’m sure I’m doing something dumb, but haven’t determined what.

First I put a computed field on the page with the intention of just displaying a value on the document I’ve found. I’ll tackle opening the document once I know I can find it.

My code looks like this:

1: var comp = getComponent(“ukey”).getValue();
2: var doc = database.getDocumentByID(“NT0000093E”);
3: return doc.getValue(“form”);

The Error is:

Script interpreter error, line=2, col=20: Exception occurred calling method NotesDatabase.getDocumentByID(string) null

The first line is meaningless at the moment. I have another computed field on the XPage that contains the key. I can get that no problem.

But because of the error, I decided to hardcode the key it. It it still says null.

Any advice would really be appreciated.

Thanks!

Dave

Subject: Can’t Get a Document in XPages via backend.

From the help, it looks like you need to remove the NT prefix. Is that the problem?

Subject: Wow!

I’ve gotten to little guidance from the HELP in regard to XPages I didn’t even think of looking up getDocumentByID. but you’re right. It says get rid of the “NT”.

I’m not sure what you mean when you say you can’t get a document via the backend in XPages. Maybe our terms are different?

I use the backend objects to get handles on different documents.

var doc:NotesDocument = vUserName.getDocumentByKey(getComponent(“computedName”).getValue());

return doc.getUniversalID()

Now I just need to figure out how to OPEN a document that I got a handle on. :slight_smile:

Thanks for the info!!!