Set the Hidden Field Property

Consider a new custom layout created for the Opportunity object with an Opportunity Type custom field.

The Opportunity Type field is a fixed choice list with values: Purchase, Lease, and Trade in. When the Opportunity Type is Trade in, a Trade in value is required. So, the Trade in Value field should appear only when the Opportunity Type field is set to Trade in. You can do so by defining the Hidden property.

Make a Field Conditionally Hidden

To set the Hidden property for the Trade in Value field:

  1. Navigate to the Details Page Layouts section of the Opportunity object.

  2. Select New Custom Layout.

    The Details Layout page appears.
  3. Click the Trade in Value field.

  4. In the Layout Properties section, select Expression from the drop-down list of the Hidden property.

    An Expression Builder icon appears next to the property.
  5. Click the Expression Builder icon.

    The Advanced Expression page appears.
  6. From the Depends On field drop-down list, select Opportunity Type.

  7. Enter the following expression in the Edit Script section:

    if (OpportunityType_c == 'TRA') return false;
    else
    return true;
  8. Click Ok.

    The Edit UI Properties page appears with the expression next to the Hidden property.

  9. Click Save and Close.

  10. Click Done on the Details Layout page.

    The Trade in Value field now appears only when the Opportunity Type field is set to Trade in for the current layout.