function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

How does validation rules gets executed?

Hello All,


I am very new to the The question I have is how is validation rule gets executed on a given object?  I see that validation rules are set within the sobjects/custom objects itself. For example, if I want to set validation rules on Account tab, then I would go to Account object to set validation rules. What I am having a hard time understanding from a design/sequential flow is who calls the validation rules? Is the Controller responsible for calling the validation rules on sObject/custom object before saving the data in the database?


Thanks for your valuable response in advance!




This page describes the save order in salesforce:


It'll show you the gamut of things that happen when you insert/update/delete/undelete a record on the platform be it via apex, API, or the UI itself. 


Look at you'll see where validation rules are ran. 


If you're wondering if validation rules are ran in javascript or on the server via the controller, they are ran on the server side.


Thanks so much for the link! That is exactly what I was looking for to understand the flow of events in I am also wondering if there is a diagram that shows the flow of events sequentially. I can create one myself going through the link but if there is one, that will surely help as well!


Again, thanks so much for the relevant link and for your prompt response!




I re-read the link again, the link does not specify how are validation rules executed both on the presentation and business tier side. It merely says that, in general, executes the validation rules. I am trying to understand within architecture, wheather the controller or some other components calls the validation on both presentation and business tiers. I hope my question make sense :-)


Thanks again in advance!