A simple workaround for OpenDocumentByKey

A simple workaround for OpenDocumentByKey

Since, well, like “ever”, it’s possible to open a Notesdocument in the browser by using the first sorted column in a view as the key. Something like:

http://server/database.nsf/sortedview/yourkey?OpenDocument

Since a couple of years, we can also use notes://-links. Very neat if you want to open a database, view or document directly in Notes. What if you want to use a key in a view for opening a document in Notes?

notes://server/database.nsf/sortedview/yourkey?OpenDocument

… doesn’t work.

After spreading my wings on the web, I found:

OpenDocumentByKey

The OpenDocumentByKey command was added in Notes 8.5 to support the ability to open a document by specifying a view and a key within that view. The definition of key is the same as the Domino server uses in here as used in the OpenDocument method. The client preferred to be more explicit by creating a new command to prevent conflicts that could occur with certain keys and document identifiers.

notes://acme/register.nsf/Registered+Users/Jay+Street?OpenDocumentByKey

Great! It may be working within their acne domain, but it certainly doesn’t work overhere! “The document specified by the link cannot be located within the linked-to database.” And the fix is deferred to a future release.

We have 2 options: say to our client that IBM knows about the problem and that a fix is deferred to a future release (sorry for that) :-) OR we create a simple alternative.

I created a page notesredirect: it redirects a http url to a notesdocument link. I like simple namings :-). There’s a computed field on it that does a @DbLookup in the sorted view, using the key you initially wanted to use.

Follow these steps:

  1. Create a page notesredirect (or whatever name you prefer) and set it as pass through.
    passthrough
  2. Write some simple html that does the redirecting:
    <html>
    <head>
    <meta http-equiv="Content-Language" content="en-gb">
    <meta http-equiv="refresh" content="0; url=<Computed Value>">
    </head>
    <body>
    </body>
    </html>
  3. For the computed value:
    key:=@UrlQueryString("ref");
    unid:=@DbLookup("":"NoCache";"":"";"vREF";key;1;[ReturnDocumentUniqueID]:[FailSilent]);
    @If(unid="";"./refnotfound?OpenPage&ref="+key;"notes://server/"+@WebDbName+"/view/"+unid+"?OpenDocument")
  4. Create a page refnotfound to show an error page to the user if for some reason a document could not be found.
  5. To use it, you need to create your url in this form:
    http://server/database.nsf/notesredirect?OpenPage&ref=xxxxxxx

It’s not high-tech and it’s old school, but it works :-).

2 Comments

  1. Nice ! You must have read my mind. Just what I needed :-)

    Reply
  2. Very clever ;-)
    Thank you

    Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

68 − = 67

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>