1. UNSTORED CALCULATIONS
When are unstored Calcs useful and when should they be avoided?
It depends!
Unstored calculations can be useful and can be used as long as we are aware of what the limits of sensible application are. Used inappropriately they can slow execution to a crawl. The reason for this performance hit is that an unstored calculation will revaluate frequently and thereby create an unnecessary load which becomes noticeable on a more complex system and/or a system with more records and larger amounts of data especially when those effects are multiplied by network latency.
Types of appropriate use
GENERALLY: Use auto-enter fields rather than calculated fields whenever possible because they will only re-vevaluate when necessary, if you permit them to over-write existing values.
LOCAL or NEARBY: use calculation fields only for things in the local table, or one hop away for gathering lists, avoid using for aggregation of data.
DATA CACHING: a calculation field can provide, for example, a snapshot of the entire record data in JSON form. Such a field could hold data from related records forming a cache available for use without further communication with related records. In this case controlling the re-evaluation of the calculation is important. An auto-enter field may offer a more controlled method?
DATA DISPLAY: consider using a button-bar to display unstored calculated data without adding the field to the layout. Be careful that you aren't triggering unnecessary requests to the server for data you don't need. Remember that Button Bars and Repeating Fields resize proportionally.
CONDITIONALLY HIDDEN: consider displaying data in a hidden object using an unstored calculation because the calculation will only evaluate when you display the object providing some control of the load created. Use a Hide Object control, Pop-Over or an inactive Panel whether Tabbed or Sliding. However, since FM18 fields (excluding containers which are streamed only to what you can see) placed out of sight in the developer area to the right of the layout are calculated although they cannot be seen.
MERGE VARIABLES: consider using a calculation to set a merge variable to display data, perhaps from several fields, as a single object, or use merge fields. Local $var used in the UI remain record specific whereas Global $$var are not.
VIRTUAL LISTS: when creating virtual lists unstored calculations are handy if not essential.
Nick Lightbody
13/03/2021
Thanks to the following for their contributions:
- Cecile
- Torsten
- jormond
- Malcolm
- mipiano
- harvest
- Vincent_L
- Bobino
- jwilling
- steve_ssh
- AndyHibbs
- tonywhitelive