Notes doesn't accept seemingly correct formulas
madicon.de/Tipps & Tricks/Notes doesn't accept seemingly correct formulas

Notes doesn't accept seemingly correct formulas

A formula that looks syntactically correct is rejected by Notes with the message "No main or selection expression in formula".
notion image
Formula example with error message
 
Even after checking several times, no error can be found – yet Notes still refuses to let you save the formula.
 

Cause of the formula error


Notes expects a return value for every formula. In other words, a value that can be returned to the "calling" instance (e.g. a field, a button on a form or an action button). For fields this makes sense – after the formula has executed, a result value is supposed to be written into the field.
For buttons on a form or for action buttons, however, one rightly wonders what this behavior is good for – the return value isn't needed here. Nevertheless, Notes stubbornly "insists" on a return value.
 

Why have I never run into this error myself?


Pure luck. In most cases – especially with formulas in fields – you "automatically" program in such a way that a return value is produced. THAT is then intended to be the desired field content. But if you (as in the example) create an action button that writes values into "some" fields, something like this can happen more easily.
 

Solution


At the end of the formula, a return value must be "generated" in any case. Most Notes developers use two quotation marks ("") or the reserved keyword NULL for this. Both mean "nothing" in the formula language – but Notes accepts them as a valid return value.
Both variants have the advantage that, for example when used within a field formula, the field stays empty. When using @True, a numeric one (1) would end up in the field in case of doubt.
tmpLastName := "Dillmann"; tmpFirstName := "Manfred"; FIELD Contact := tmpFirstName + " " + tmpLastName; "";
In this form Notes accepts the formula from the example above. So the cause is definitely NOT – as is often assumed – the semicolon at the end of the last statement line.
 

Amazon Affiliate Link
notion image