Common Errors in Field Formulas

Mathematical calculations with empty or non-numeric values

When doing any kind of mathematical calculations in formulas, all used values must contain a numeric value. If a field needed in the calculation does not yet contain a value, like when the entity is first created, a default value can be assigned to a variable with the `default` modifier.

{math equation="a+b" a=$field1|default:0 b=$field2|default:0}


Also, note that the value of a field might change during the execution from a previous formula and it’s extremely important to ensure the result is a valid numeric value. Most common errors happen when a formula results in a value with trailing whitespace.


Division by zero error

Always ensure your formula does not result in division by zero. The easiest way to avoid this is by adding a condition around the calculation.

{if $my_field != 0}{math equation="a/b" a=1 b=$my_field}{else}1{/if}


Field name variants

Depending on where the dynamic field formula is used, field names may have variants. So if the dynamic field formula is not working, you might want to check the article Field name variants Legacy vs REST/CRM2.

Combined Shape