Avoiding formula errors
iQ.Suite Tips & Tricks for IBM Domino
How do I safeguard myself from formula rules which are syntactically ok, but which still don't work because, for example, different value types are being compared (text with date)?
- In this example, a date value (@created) is compared with text ("now").
- The syntax of the formula is perfectly correct. However, because it is not possible to compare text with a date, iQ Suite stops processing the email and issues an error.
(extract from the iQ Suite log)
- In order to stop the system hanging up completely, the result of the query is sent to an auxiliary field ("_result“, for example).
If there is an error, the auxiliary field contains an appropriate
error message; if the query does not result in an error, it contains
the values "false" or "true". If an error ("@IsError") occurs, it
contains the result "false" otherwise it shows the result of the actual
query ("true" or "false").
This ensures that the rule formula can only return the permitted values "true" or "false" and does not cause the rules to hang.
There is a nice example of a query like this in the iQ.Suite sample rules:
Formula rule: NoBodyDom7
_HasText := @trim(@Abstract([ABBREV]; 1000; ""; "body" ))!="";
_Hasp7matta:= @contains( @lowercase( @AttachmentNames(0));"smime.p7" );
_isEmpty:=@If( !_isAvailable | ( !_HasText & !_Hasp7matta) ;@TRUE;@FALSE);