Carry out the following steps to create a validation rule to ensure that the reason why an opportunity has been lost is captured whenever an opportunity is recorded as lost:
- Click on the Setup gear icon in the top right-hand corner of the main Home page, as shown in the following screenshot:
- Click on Setup, as shown in the following screenshot:
- Navigate to the Opportunity Validations Rule setup page by clicking the following: Objects and Fields | Object Manager | Opportunity | Validation Rules.
Locate the Validation Rules section on the right of the page.
- Click on New.
You will be presented with the Opportunity Validation Rules edit page.
- Type Opportunity Reason Lost in the Field Label textbox.
- Upon clicking out of the text box, the name of the field label changes to Opportunity_Reason_Lost.
- Leave the Active checkbox set.
- Optionally, enter details in the Description field.
- Navigate to the Error Condition Formula section.
- Paste in, or enter, the following code:
AND( NOT(IsWon), IsClosed, ISBLANK(TEXT(Reason_Lost__c)) )
- In the Error Message section, enter the text: Please select an option for the Opportunity Reason Lost field.
- For the Error Location option, select Field.
You will be presented with the Field selection pick list.
- Select the field Reason Lost.
- Finally, click on Save, as shown in the following screenshot: