Although Salesforce does not fully support dynamically required fields, you can use the dependent picklist feature from the Winter ’06 release to implement this functionality when the field to be required is a picklist field and it’s requirement-rule is based upon another single picklist (or checkbox) field. To illustrate, the following requirement is common for many sales organizations and can use dependent picklists to fulfill it.
Require the end user to select a Reason Lost when the Opportunity Stage is set to ‘Closed Lost’
The steps to accomplish this are:
- Create a custom picklist field called ‘Reason Lost’ on the Opportunity Object.
- After creating the field, add a Field Dependency with the Stage as the controlling field.
- Associate all of the Reason Lost values with the Closed Lost controlling value.
- Add the Reason Lost field to the Page Layout and require that field.
- You are already finished!
Here it is in action. While the Stage is set to values with no corresponding Reason Lost values, the Reason Lost field is read-only and is not required. Once the Stage is changed to Closed Lost, the Reason Lost field becomes read-write and is required.