Providing an Expression to Make a Custom Field Conditionally Updateable

A custom field can be updatable or read-only. By default, any non-formula field is updatable. Or, you can configure a conditionally updatable expression.

If you do this, it's evaluated each time a page displaying the field is rendered or refreshed. The expected return type the expression is boolean. If you define one for a field, you must also configure the Depends On list to indicate the names of any fields on which your conditionally updatable expression depends. By doing this, your conditionally updatable field will interactively enable or disable as appropriate when the user changes the values of fields on which the conditionally updatable expression depends.

For example, consider a custom TroubleTicket object with Status and Justification fields. Assume you want to prevent a user from editing the justification of a closed trouble ticket. To achieve this, configure the conditionally updatable expression for the Justification field as follows:

Status_c != 'Closed'

After configuring this expression, you must then indicate that the Justification field depends on the Status field as described in Understanding Automatic Dependency Information for Cascading Fixed-Choice Lists.. This ensures that if a trouble ticket is closed during the current transaction, or if a closed trouble ticket is reopened, that the Justification field becomes enable or disabled as appropriate.

Tip:

A field configured with a conditionally updatable expression only enforces the conditional updateability through the web user interface in this release. See Enforcing Conditional Updatability of Custom Fields for Web Service Access for more information on how to ensure it gets enforced for web service access as well.

Caution:

It's not recommended to assign a new value to any field as part of the code of a conditionally updatable expression. The script can consult the value of one or more fields, but should not assign a new value to any field in the row. Doing so will cause unexpected behavior in the user interface, may impact runtime performance, and can cause deadlocks.