Start/Tip(p)s & Tricks/Faster Display of Documents

Faster Display of Documents

Documents whose underlying form uses the @DbLookup or @DbColumn functions often take a comparatively long time to display when opened in the Notes Client — even when the documents are only viewed in "read mode".
 

Why is that?


This is because certain computed or editable fields execute their formulas even when a document is opened in read mode.
You cannot prevent the field formulas from executing, but the "lookup functions" don't always need to be run.
 

What can you do as a developer?


In the relevant field formulas, the "lookup functions" should not be executed when a document is only being opened for display on screen in the Notes Client. The @If function is the key here.
 

1. Example: Keyword list formula with @DbColumn

@DbColumn(class:cache; server:database; view; columnNumber)
should be changed to:
@If( !@IsNewDoc & @IsDocBeingLoaded; @Return(""); @DbColumn(class:cache; server:database; view; columnNumber) )

2. Example: Keyword list formula with @DbLookup

@DbLookup(class:cache; server:database; view; key; columnNumber; keywords)
should be changed to:
@If( !@IsNewDoc & @IsDocBeingLoaded; @Return(""); @DbLookup(class:cache; server:database; view; key; columnNumber; keywords) )

Note on the @Return function

From the HCL Online Help:
Immediately stops the execution of a formula and returns the specified value. This is useful when you only want the remainder of the formula to be executed only if certain conditions are True.