IBM®
Skip to main content
    Country/region select      Terms of use
 
 
   
     Home      Products      Services & solutions      Support & downloads      My account     

developerWorks  >  Lotus  >  Forums & community  >  Best Practice Makes Perfect

Best Practice Makes Perfect

A collaboration with Domino developers about how to do it and how to get it right in Domino

@DbLookup and @DbColumn have a little quirk that's not made really clear by the documentation. If you use an @Dbfunction against a view that the user has re-sorted by clicking a column heading, the @Dbfunction will return a result based on the user's selected sort order of that view, rather than using the default sort column (also known as the "primary collation"). This is true even if the view is not open at the time. I refer to this euphemistically as a "surprise feature." There are other names for it, one containing three letters and others containing four.

As you might imagine, problems caused by this disconnect between developer expectation and actual functionality are hard to track down, because when a developer tries to reproduce it, the view is probably not sorted the same way on their workstation as it is for the user having a problem. The user may not even have used the view in weeks -- it doesn't matter how long ago, their workstation remembers their custom sorting.

So this is one reason to use a separate, hidden view for your lookups -- even though you get better performance with fewer views. Another reason is maintainability -- user views are more likely to change than purpose-built lookup views. If someone adds or moves columns and you have a hardcoded column number in a lookup to that view, there'll be a problem.

Another little-known tip about lookups tomorrow.

Andre Guirard | 25 March 2008 05:07:00 AM ET | Caribou Coffee, Minneapolis, MN, USA | Comments (3)


 Comments

1) Three things you may not have known about @Dbfunctions - thing 1
harkpabst meliantrop | 3/25/2008 8:24:46 AM

"So this is one reason to use a separate, hidden view for your lookups -- even though you get better performance with fewer views."

I'll support that statement every day and in every way. And I account it to me obeying this practice, that I never even noticed this ... err, how did you call it? ... su... no, that was wrong ... surprise feature.

2) Three things you may not have known about @Dbfunctions - thing 1
Nathan T. Freeman | 3/25/2008 8:39:18 AM

Hrmmm...

I want to figure out some ways to use this to my advantage. I bet you could get some sweet behavior out of the Notes client if you did a bit of.... tweaking. :-)

3) Three things you may not have known about @Dbfunctions - thing 1
Timothy Briley | 3/26/2008 9:36:38 AM

Does the same hold for LotusScript? For example does doc = view.GetDocumentByKey("cat") return an unexpected result if the user has first resorted the view?

4) Three things you may not have known about @Dbfunctions - thing 1
Erik Brooks | 3/27/2008 8:00:38 AM

Yes, it does. IIRC you will actually *change* the lookup column altogether.

E.g. if you have a 2 column view and column 1 is the default sorted column then view.GetDocumentByKey runs against column 1.

But if the user resorts on column 2 then view.GetDocumentByKey runs on column 2.

So your first search might find a hit, your second might find a different hit or none at all!

 Add a Comment
Subject:
   
Name:
Comment:  (No HTML - Links will be converted if prefixed http://)
 
Remember Me?     Cancel

Search this blog 

Disclaimer 

    About IBM Privacy Contact