What formulas run when Relate data is edited?  This may seem a simple question, but it is far more complex than might be imagined.  When editing a form entry many actions take place.  For any given form entry, the steps always occur in the same order, but some steps may be skipped depending on the circumstances.  First we will look at the case of a single form being updated.  Simultaneous edits to multiple form entries will be discussed in the next section.

  1. Default values are applied based on field settings.  This step is skipped if the entry is not being created (or filled out for the first time).
  2. Pre-edit formula run.
  3. User edits are applied.  This step is very complicated. The process may stop here.  Also, the first three steps may be repeated several times before proceeding to the next step.  More details are given below.
  4. Field formulas run.  There also is a specific order in which field formulas run, if there are formulas on multiple fields.  See the section on field formulas for details.
  5. Pre-save formulas run.
  6. Data is saved.
  7. Post-save formulas run.
  8. Data is saved a second time.  This step is skipped if no data was changed during step 7.

Details about step 3:  Step 3 is a major decision point.  There are many factors which determine whether the process will continue or stop at this step.

Multiple Forms and Multiple Formulas
Often pre-save and post-save formulas are used to change data on one form when another is edited.  What happens when multiple formulas are changing data on multiple forms?  Relate keeps a list of all the form entries that are being edited in the current operation.  It attempts to keep all edits on the same step in the edit process.  Also, it never allows returning to a previous step during the current operation.  The only way any step will be repeated is if the entire operation is halted by the user during step 3, then continued on another page.  This would constitute a separate operation with the first three steps re-applied from the previous incomplete edit.  Let's look at an example. 

Example:  Imagine a form, FormA, with a pre-save formula, FormulaA, that modifies data on a second form, FormB.  FormB has a post-save formula, FormulaB, which modifies data on FormA.  What happens when the user edits data on FormA? 

Okay, now we know what happens if the user edits FormA.  But what happens if the user instead chooses to edit FormB?

You can imagine the complexity of determining the order in which things happen when there are more formulas modifying more form entries.  This is important because a formula programmer may try to write formulas which depend on values calculated by other formulas.  For instance, FormulaB runs before FormulaA only when FormB is being edited.  If FormulaA depends on results calculated by FormulaB the formula author must be sure that FormulaA will still work correctly in this case.