Validation Rules in Flow
Last updated
Last updated
Salesforce introduced a new way of creating validation rules using flows a few months ago. This blog post will show you how to create a validation rule flow to prevent users from moving an opportunity to the "Use Case Defined" stage without completing the "Terms in Months" field.
Salesforce org with the "Flow Builder" permission
Opportunity object with a "Terms in Months" field and a "Stage Name" field
Create a new flow from the Flow Builder.
Select the "Record-Triggered Flow" template.
Set the following flow properties:
Flow Name: Validation Rule Test
API Name: Validation_Rule_Test
Trigger: Record is updated or created
Object: Opportunity
Keep the entry conditions wide for simplicity.
Rename the flow to "Validation Rule Test".
Decide if you want one validation per flow record or if you want to use one flow that combines all the validation rules.
Create a validation rule for the specific scenario:
Criteria: Stage Name is changed
Condition: Terms in Months is null
Stage Name is equal to "Use Case Defined"
Save the validation rule.
When the conditions are met, include a "Custom Error" element in the flow.
Configure the custom error message:
Label: Custom Error Message
Display Type: In a window
Message: Please add Terms in Months to move into the Use Case Defined stage.
Activate the flow.
There are two clear benefits of having validation rules as flows:
Validation rules in a flow can be executed first before every other flow, which prevents users from seeing confusing error messages.
You can have one flow that aggregates all the other validation rules on an object, making it easier to manage and maintain validation rules.
Validation rule flows are a powerful tool that can be used to improve the user experience and enforce data integrity in Salesforce. By following the steps in this blog post, you can easily create validation rule flows to meet your specific business needs.