Assigning a Value to a Field in the Current Object

To assign the value of a field, use the Groovy assignment operator = and to compare expressions for equality, use the double-equals operator == as follows:

// Compare the ContactTwitterName field's value to the constant string 'steve'
if (ContactTwitterName == 'steve') {
  // Assign a new value to the ContactTwitterName field
  ContactTwitterName = 'stefano'
}
Tip: See Avoiding Validation Threshold Errors By Conditionally Assigning Values for a tip about how to avoid your field assignments from causing an object to hit its validation threshold.