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

Timothy Briley asked:


I've noticed that over time you've written a bit about valid searches in Lotus Ntoes. Can you comment one way or another on whether or not this is a valid search method:
To find documents in a view containing an empty date field manually by using the search bar or programatically using notesView.FTSearch:
Not([fieldName] > 0)
If this is a valid method, why isn't it documented?

It is seems to work for you, fine. Many things are not documented. Sometimes this is because the developer didn't tell anyone about it, sometimes because it wasn't a planned feature (as I suspect is the case here), and sometimes because we don't want to commit to supporting it indefinitely. When you try to make each version of a product able to support applications created in all previous versions, you have to be careful about what you call a supported feature.
So in general, if something is not documented, you should use it with care and make a special point to test it out before you upgrade your Notes/Domino installation, to make sure it still works in the new version.
In this case, there's a supported way to do what you're looking to do. The "is present" syntax, which is documented, will let you find documents that do, or do not, contain a value in a given field.
However, depending on your application, this may not be the most efficient way to do your search. Please see the wiki article Searching for Documents for some guidelines.

Andre Guirard | 31 October 2011 06:15:00 AM ET | | Comments (5)


 Comments

1) Searching For Blank Date Fields
Timothy L Briley | 10/31/2011 11:12:47 AM

"In this case, there's a supported way to do what you're looking to do. The "is present" syntax, which is documented, will let you find documents that do, or do not, contain a value in a given field."

Response:

"is present" does not work for date fields. Notes returns "Query is not understandable". This has been known for at least 5 years.

Details:

"is present" was made known to most of us via Alan's post in March 2006. But in the comments to that post it became clear that it doesn't work for date fields. For example, read comment #14:

{ Link }

Since "is present" doesn't work for date fields, I kept searching for something that does. I found it in the same post in comment #34 made almost 4 years later.

Summary:

Since "not([Datefield] > 0)" works and "not([Datefield] is present)" does not, I'd really like for the one that works to be documented and supported. But since it's not, I'll be sure to test for it before rolling out a new release.

2) Searching for blank date fields, and what makes a supported feature
Andre Guirard | 10/31/2011 1:18:29 PM

In that case, you may be safer comparing to a date value rather than a number. E.g. if you use not ([field] > 1/1/1900) I imagine that will return all the blank ones and you're less likely to get burned by some Lotus developer saying, "wait, shouldn't we test that the value they supply is really a date?" and 'fixing' it.

3) Timothy Briley
Timothy L Briley | 10/31/2011 3:35:07 PM

Good idea. I tested it and it works.

BTW, the official documentation referred to in the wikidocument you linked to: { Link }

needs this:

[fieldname] IS PRESENT can be used to test whether a field is non-blank.

changed to this:

[fieldname] IS PRESENT can be used to test whether a field is non-blank if it isn't a date/numeric field.

And while it's being corrected, it would be nice to have this added:

[fieldname] > 1/1/1900 can be used to test whether a date field is non-blank

and

([fieldname] > 0) Or ([fieldname] < 0) Or ([fieldname] = 0)

can be used to test if a numeric field is non-blank

4) [date] > 0
Nicolas Melay | 5/11/2012 12:47:41 PM

"[datefield] > 0" fails for dates anterior to 1/1/2000 (at least, it does so with the French locale).

"[datefield] > 1/1/1900" indeed looks like the way to go.

Also, searching multi-value date or numeric fields yields some strange results...

 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