Expression Builder for Object Workflows

Use the expression builder to write Groovy-based application logic that determines when an object workflow is triggered.

An expression builder supports building logical and math operations, including field lookups that you can optionally use to define trigger conditions. Fields in the expression builder are populated based on the object for which you're defining the workflow. The expression builder displays a warning if your expression contains an invalid attribute name; however, you must confirm whether the attribute name is actually invalid. If an attribute exists which was created at runtime, then you can safely ignore the warning.

Note: Object workflows aren't triggered when records are created through Import Management. Import Management bypasses any Groovy validation and trigger logic on an object.

Some examples of the raise conditions you can use include the following:

Example 1:

Status=='IN_PROGRESS' && BudgetAvailableDate==Today() + 30

Example 2:

if (isAttributeChanged('PrimaryContactPartyName') && 
PrimaryContactPartyName =='Business World')  return true;  else  return false; 

Example 3:

WinProb>10 || WinProb<50 

Consider the following when using the expression builder to create conditions:

  • Ensure that you return a valid Boolean as part of your raise condition. Returning a non-boolean value could lead to runtime errors.

  • Use return true or return false to explicitly return the Boolean value and code indentation when the evaluation logic is complex, to minimize risk of runtime errors.

  • For lookup values, use the lookup code instead of the display value.

  • Use <, >, == for comparison.

  • For the event point When a record is updated, avoid redundant calls of the actions by always specifying which field change should trigger the object workflow, using the function isAttributeChanged().

  • Don't base your object workflow's isAttributeChanged() condition on a long text (CLOB) field. Instead, create a field-level trigger (or object-level trigger with an isAttributeChanged() condition) on the long text field to update a dummy text or number field. Then, you can define your object workflow condition using isAttributeChanged(NewDummyField).

  • Be aware of Groovy-type coercion, if you're not returning an explicit Boolean value.

  • Use the logging capability to debug your condition and review the generated log by selecting Runtime Messages in the Common Setup pane.

For more information on Groovy scripting, see the Groovy Scripting Reference guide.