A Guide for Using Validation Rules Beyond the ‘Save’ Event

In the ever-evolving world of Salesforce, admins and users often encounter challenges that require creative solutions. One such challenge is the implementation of validation rules in scenarios other than the standard ‘Save’ event. This blog post delves into the heart of this issue, exploring practical workarounds to extend the functionality of validation rules, particularly before the delete event.

The Challenge at Hand

Salesforce’s validation rules are powerful tools for maintaining data integrity and enforcing business processes. However, their trigger is traditionally limited to the ‘Save’ event. What if you need these rules to fire under different circumstances, like before deleting a record? This is where ingenuity comes into play.

Workaround 1: The Power of Flows

One ingenious solution comes from the Salesforce Winter ’24 update, which introduced a new feature allowing the prevention of record deletion through custom errors in flows. Here’s a step-by-step guide:

1. Create a Record-Triggered Flow: This flow should be set to trigger when ‘A record is deleted’.

2. Evaluate Triggering Conditions for Error: Leverage flow logic through get elements, looping, decisions, etc. to evaluate the criteria for triggering the error message.

3. Custom Error Handling: Once you’ve evaluated the triggering conditions, select the ‘Custom Error’ component. Within the component, add an error message to display to the end user

This method offers a no-code solution, leveraging the power of Salesforce’s flow builder to implement validation-like logic.

Workaround 2: Checkbox Trick

1. Create a Checkbox Field: Add a new checkbox field, let’s call it ‘Delete’, on the object you want to validate.

2. Record-Triggered Flow for Deletion: Set up a ‘Before Delete’ flow that updates the ‘Delete’ checkbox to true.

Now, in your validation rule, simply check if ‘Delete’ equals true. This method cleverly uses a combination of custom fields and flows to mimic validation rule behavior.


Workaround 3: Custom App Solution

For a more robust solution, consider the Delete Helper app available on the Salesforce AppExchange. This app offers a streamlined approach to managing deletion rules across various objects like Accounts, Contacts, Cases, Opportunities, and Leads. It’s a great option for those looking for a ready-made solution.

Further Exploration

For more insights and innovative solutions in the Salesforce ecosystem, don’t hesitate to explore more content from SOLVD, a dedicated Salesforce consulting firm that offers top-tier, cost-effective solutions.

yellow cloud solvd logo

Our clients say

From my initial call with Spencer through project implementation with John and Evan, my experience with the SOLVD team was excellent. They were quick to understand our business needs, clear when explaining the reasoning behind proposed solutions, transparent when reporting on progress and timeline, and all around enjoyable to work with. Would highly recommend and looking forward to continue working with them in the future!

Veronica Wong Director of Operations at Pathstream

SOLVD was very straight forward with everything needed to complete the project. No surprises, no issues, and cost was aligned with the estimate. They made implementation easy and quick.

Matt Benzaquen Sr Manager, Sales Strategy at Instabug

As a rule, I'm pretty stingy with my recommendations. So it's a pleasure for me to recommend Solvd as a top-flight Salesforce consultancy. Solvd recently led our company's conversion to the Lightning interface and did it on time, on budget and made it easy for me and my team. I know I'll use their services again, and am confident they can do the same for you.

Tim Tuttle CFO at Relevate Health Group