logo

Serendipity Comes Calling. Twice. In ONE Day.

That lovely lady called Serendipity visited me twice yesterday.

First time was in the guise of Damjam who posted a comment here asking where to download the example I'd shown in the Export Notes Data To MS Word entry, which I'd all but forgotten about.

Just the day before I'd had a request from a client that a Form in a web application be made available in a format that could be printed out A4 and snail-mailed to the user whose address is stored in said document. My first thought was using a print-friendly form but as soon as I was reminded how easy it is to create a Word document using XML I knew this would go down a lot better — as a general rule customers love it when you integrate Office like this.

No sooner had this happened than I was browsing feeds and read Tommy Valand's post about web lookups. In it he recalls how a Google brought him to this codestore page. Although what I'd posted was of no use, a comment posted by Alex Hernandez solved his problem. Again this comment of Alex's either fell off my radar at the time or I'd completely forgotten it and failed to notice the significance of what he was saying.

I too was having problems with the fact that &startkey=foo doesn't always do what you'd want it to. In my case it was being used with Ajax to act like an @DBLookup (much like Tommy I expect). The trouble is there's no way of telling it to match the key exactly. Say you have a view called "Animals" with a sorted first column with these entries:

Antelope
Baboon
Bear
Chipmunks
Donkey
Doves
Fox
Pig
Pigeon
Pigeons
Tortoise
Yak

If you use the URL "/db.nsf/animals?Open&startkey=Pig" you would see:

Pig
Pigeon
Pigeons
Tortoise
Yak

Whereas what you might expect to see just the following:

Pig
Pigeon
Pigeons

If you enter URL "/db.nsf/animals?Open&startkey=Elephant" you might expect to see no results but would in fact see:

Fox
Pig
Pigeon
Pigeons
Tortoise
Yak

Whether this is "as designed" or not I don't know. It's just one of those quirks of Domino we're all used to. I had resigned myself to explaining away this odd behaviour if the client noticed it. That was until Tommy's post "reminded" me of Alex's workaround.

The URL "/db.nsf/animals?Open&startkey=Pig&UntilKey=Pig_" will show you the expected results of Pig, Pigeon and Pigeons! Such a simple hack but so, so useful.

If ever you use the StartKey parameter and only want entries starting with that key then use the UntilKey parameter with the same key, but with with an underscore or suchlike tagged on the end.

This all reminds me that, as a developer, you're only really as good as a) what you know and b) what you remember once knowing and have repeated access to.

It happens quite often that I go looking for solutions and end up right back here. There's stuff in here I either don't remember or, by all accounts, don't even know about. In the new year I'm thinking of having a "Content Revisited" week. A bit like the "Tips Week"s I've had in the past.

Anyway. I hope you all have a great Christmas and I'll probably see you between then and the New Year.

Comments

  1. Merry Christmas to you too Jake!

  2. UntilKey! Awesome! How is it I never knew about that?

  3. It's not the first time I've found something useful in your comments sections. It's a goldmine!

    Some commenters want to show the author their better way of doing things. Sometimes it's annoying/off-topic/etc, and sometimes, like in this case, it's gold.

    --

    Merry Christmas Jake!

  4. Hi Jake,

    On the same subject, just had to do some work where all web generated reports + 61 graphs per report!! were needed in Acrobat from dynamic data. (web Survey).

    I've found that people seem to like pdf files more than word where editing is not required.

    Used Java, iText & JFreeChart...Worked a treat.

    If you, or any of your readers would like sample code let me know...I've had enough stuff off you over the years!

    Rgds

    Nick

    • avatar
    • Mark C.
    • Fri 28 Dec 2007 12:40 PM

    Hey Nick,

    That sounds like something I'd like to see a sample of.

    Thanks in advance,

    Mark

Your Comments

Name:
E-mail:
(optional)
Website:
(optional)
Comment:


About This Page

Written by Jake Howlett on Fri 21 Dec 2007

Share This Page

# ( ) '

Comments

The most recent comments added:

Skip to the comments or add your own.

You can subscribe to an individual RSS feed of comments on this entry.

Let's Get Social


About This Website

CodeStore is all about web development. Concentrating on Lotus Domino, ASP.NET, Flex, SharePoint and all things internet.

Your host is Jake Howlett who runs his own web development company called Rockall Design and is always on the lookout for new and interesting work to do.

You can find me on Twitter and on Linked In.

Read more about this site »

More Content