logo

Bug With UntilKey URL Parameter

Almost a year ago I talked about how you can get Domino's UntilKey URL parameter to make its StartKey counterpart do what you'd expect it to -- return only exact matches from the first column in the view. If you had a sorted view of animals you could return all those who were Cats use a URL like this:

animals?ReadViewEntries&StartKey=Cat&UntilKey=Cat_

All's well and good and I've used the the trick repeatedly since, not knowing how I managed without it.

Then this week I was talking about using lists in the first column of a view to allow flexible lookups. Again, all was good. Until I tried to search for the last document in the view. In the example it's a car called Zonda. Type in "Z" and nothing comes back.

The bug: It looks like the UntilKey trick doesn't work on views sorted by a multi-value column. It just won't return the last document.

Taking the example of the cars here's an empty result set for "Z" and here's what you'd expect to see, which points to a view with a normal single value column.

Just another reason not to trust Domino to give you want you want and to go you own way. For me I'll be using my Ajax NotesViewNavigator Object. No doubt there's a performance hit, but at least it does what you want it to.

Comments

  1. The number of (@)elements in a formula text list is equal to the last index in the list.

    Arrays in JavaScript/Java/etc has a length/size that is equal to the last index + 1.

    When writing a for for-loop, I sometimes forget that the number of elements is equal to the index of the last element.

    Could it be that the engineer that wrote the backend-code made an error due to programming-language confusion?

    If so.. Where's the quality control?

    • avatar
    • Rene Scheening
    • Fri 3 Oct 2008 04:39 AM

    In my experience untilkey doesn't return anything whenever the last document in a view is reached, no matter how the view is build.

    I use a view (not categorized, all columns are single-value fields) sorted by month/year and I use startkey and untilkey to get a particular month. I had to add a fake document containing dec. 2999, otherwise the last month wouldn't show up.

    • avatar
    • Rafael
    • Mon 6 Oct 2008 05:34 AM

    Hi to all

    I had developed the following workaround to solve this, the solution is about sum one to the string ASCII charcode to search.

    This is as follows:

    sStartKey = <Computed Value>

    @URLDecode("ISO-8859-1"; @UrlQueryString("startkey"))

    sUntilKey = sStartKey.substr(sStartKey.length-1,1);

    switch( sUntilKey){

    case 'à': case 'á': case 'â': case 'ã': case 'ä': case 'å': case 'æ':

    sUntilKeyToSearch = sStartKey.substr(0,sStartKey.length-1) + 'b';

    break;

    case 'è': case 'é': case 'ê': case 'ë':

    sUntilKeyToSearch = sStartKey.substr(0,sStartKey.length-1) + 'f';

    break;

    case 'ì': case 'í': case 'î': case 'ï':

    sUntilKeyToSearch = sStartKey.substr(0,sStartKey.length-1) + 'j';

    break;

    case 'ò': case 'ó': case 'ô': case 'ö': case 'ø':

    sUntilKeyToSearch = sStartKey.substr(0,sStartKey.length-1) + 'p';

    break;

    case 'ù': case 'ú': case 'û': case 'ü':

    sUntilKeyToSearch = sStartKey.substr(0,sStartKey.length-1) + 'v';

    break;

    case 'z': case 'Z':

    sUntilKeyToSearch = sStartKey.substr(0,sStartKey.length-1) + 'zz';

    break;

    default:

    sUltimaLetraBuscar = sStartKey.substr(0,sStartKey.length-1) + String.fromCharCode(sUntilKey.charCodeAt() + 1);

    break;

    }

    I hope this helps.

Your Comments

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


About This Page

Written by Jake Howlett on Fri 3 Oct 2008

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