top of page
Writer's pictureMichael Kolodner

Cooler Than Validation Rules

I've been working on an approval process for a client lately. I bet that's for a sentence you don't hear too often. But despite not having gotten updates in ages, they're a pretty cool feature. However, this post isn't actually going to be about approval processes. It's just that our story starts there.

Freebie the Puppy in a house next to a river that is turning a waterwheel so it flows (get it!?!) into a hose and a trough next to his house.

You see, I had a pretty simple requirement: Each step in the approval would move a record to the next stage. But we wanted to require certain fields be filled out at certain stages, as the record advances through the approvals. Page layout tricks wouldn't be the answer, since some approvers would only be approving, not editing the record. Time to write a validation rule.


Only when I started testing, I found that records kept changing status and ignoring the validation. Thing I Learned: The workflow field updates that happen within an approval process do not fire validation rules. Fortunately, a few minutes' searching found me at this blog post, by Yumi Ibrahimzade, with a workaround. Build a before save Flow that checks if the record has certain conditions and then use a custom error component to show an error, similar to a validation rule. Problem solved!


So interesting! I had never used the custom error component before.


Idea! 💡

That got me thinking. This custom error on a before save Flow is pretty neat! Cooler than validation rules 😎 on a lot of levels.


With branching logic and all the other powers of Flow, you could get super custom with what kind of validations you want. For example, you can make cross-object validations, that check the status of related records, not just fields on the record itself. Or you could validate based on non-record statuses, like day of the week, or user attributes, or even custom metadata records. Here's Yumi combining custom errors with Flow fault paths, so fault paths don't cause a Flow to fail silently for the user.


I want to use these before save validation flows everywhere!


Reality 🥱

But in truth, I'm sticking with validation rules. Sorry to be the splash of cold water. Validation rules have two major advantages:


Transparency

As much as the backwards formula logic of validation rules constantly trips me up (and it does!), they live right within the object manager. You can see all the validations for a particular object in one place.

The Validation Rules tab of a custom object in the Object Manager.

And you can also see what validation rules relate to a particular field right within that field's edit page.

The detail page for a field, with the related list of Validation Rules at the bottom.

Ease of Maintenance

I absolutely love Flow. But it takes more than a handful of clicks to make a new one. Or to open an existing one. Or even to activate and deactivate flows that are already built. And don't even get me started on the pile of Flow versions. So if you need a validation rule that can be built with a rule, it's going to be far faster to create a validation rule. Fewer clicks = happier admins.


Let the Gears Turn ⚙️

But now that we both know about this, let it rattle around in your subconscious. Can you think of validations that would help keep your data clean that weren't suitable for validation rules?

428 views

Recent Posts

See All

Don't wait for the next post! Get them in your In Box.

bottom of page