Groovy 16- Formula Fields (Create field, Add Script To field, Add Field To Page Layout)
Formula Fields are used for running code at run-time. However, calculations in a formula field do not get stored in the database, so they are not available for reports. Using formula fields in trigger conditions can create inconsistencies due to the nature of formula fields.
It is a good idea to use a return statement in formula fields. Here is a sample of Groovy code in a formula field:
def x = 1 def z = 2 return x + z
Output: 3
Example images: