About This Code
Brief Description:
Sorted, Multiple Key, Cached DbLookup
Notes Version:
R5.x, R6.x
Last Modified:
14 Jan 2003
OpenNTF Disclaimer
All of the program code and information presented in the OpenNTF.org Code Bin are provided "as-is", and should be used at your own risk. OpenNTF.org make no express or implied warranty about anything in the Code Bin, and OpenNTF.org will not be responsible or liable for any damage caused by the use or misuse of anything from this site. OpenNTF.org makes no guarantees about anything. Please thoroughly test all of the knowledge and code you find here before you attempt to use them in your production environment.
Code / Description
Sorted Multiple Cached DbLookup
Basically, this performs the same result as
@Unique(@DbLookup(
"":"nocache";
Db;
View;
MultipleKeys;
FieldName
))
except that if any key doesn't have any documents, then @DbLookup returns an error, so instead this is done via LotusScript
in a way that sorts the values, prevents duplicates, and saves time by caching the results to that next time this function is called
it won't need to consult the View object.
Warning: values are cached by Key only. If you call SMCDbLookup multiple times passing the same key values, even against different
views, you will get the first-returned values only.
Usage / Example
Use whenever you need to do a DbLookup against multiple documents in the same view and you're concerned about performance, espcially in an agent running against large numbers of documents or on a form where users might refresh/save a document multiple times before closing.
If on a form, you can call this from the QuerySave, plus Exiting event scripts of relevant keyword fields, rather than refreshing the entire document.
Code Attachments
Comments
Posted by John Smart on 03/03/2006 11:54:14 AM@DbLookup's new FailSilent argument
FYI: In version 6 there's an optional [FailSilent] argument to @DbLookup that makes the above script much less needed.