Where You'll Use Groovy in Your Application

There are a number of different contexts where you will use Groovy scripts as you customize existing objects or create new custom ones. You will write shorter scripts to provide an expression to:

  • calculate a custom formula field's value

  • calculate a custom field's default value

  • make a custom field conditionally updateable, or

  • make a custom field conditionally required

  • define the condition for executing an object workflow

You will generally write somewhat longer scripts to define:

  • a field-level validation rule

  • an object-level validation rule

  • a trigger to complement default processing

  • utility code in a global function, or

  • reusable behavior in an object function

If you anticipate calling the same code from multiple different contexts, any of your scripts can call the reusable code you write in either global functions or object functions. As their name implies, global functions can be called from scripts in any object or from other global functions. Object functions can be called by any scripts in the same object, or even triggered by a button in the user interface.

After exploring the Groovy basic techniques needed to understand the examples, see Examples of Each Context Where You Can Use Groovy for a concrete example of each of these usages, and Groovy Tips and Techniques for additional tips and techniques on getting the most out of Groovy in your application.