Enforcing Conditional Updateability of Custom Fields for Web Service Access

Any conditional updateability expression you provide for a field is enforced only within the web application's user interface.

Depending on the condition you've provided — assuming you have correctly configured the Depends On information as described in Configuring Depends On Fields for Conditional Updateability or Conditional Mandatory — the field in the user interface will enable or disable as appropriate. However, the same cannot be said for updates to that field performed through the web service interface. Using the example from Understanding Automatic Dependency Information for Cascading Fixed-Choice Lists, if the line item's quantity field is less than or equal to five, then the fulfillment warehouse field will be disabled in the user interface. In contrast, if a system attempts to update the same line item using the web service interface, an attempt to update FulfillmentWarehouse will succeed regardless of the value of the Quantity field.

To enforce this conditional updateability through the web service as well, you need to add an object-level validation rule that enforces the same condition. For example, you would configure the following rule to prevent web service updates to the fulfillment warehouse value if the quantity is not greater than five:

  • Rule Name: Warehouse_Updateable_Only_With_Quantity_Over_Five

  • Error Message: A warehouse can be specified only for quantities over five

Rule Body

// If the fulfillment warehouse is changed, ensure the
// quantity is greater than five (5)
if (isAttributeChanged('FulfillmentWarehouse_c')) {
  if (Quantity_c <= 5) {
    return false
}
return true