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
Anitha SadhasivarajaAnitha Sadhasivaraja 

Admin to Developer

I am in the transition from Admin to Developer. Though we can handle all the validations using Validation Rule, why we are handling in coding/classes?
vineet kumarvineet kumar
Hi Anitha,

I let you know that Admin comes with so many limitations. So If you want to extend the SFDC Standard functionalities OR Custom Functionalities/logic i.g. Custom Pages, Custom Logic that cannot be handled using Admin, then we go for Coding part such as VF Pages/Apex/Triggers, etc..

If we particularly talk about Validation Rules, So there will be some scenarios where Admin level Validation Rule can't fulfill the requirement then we handle such scenarios at the code level.
    i.g. Suppose on Account, there is a custom field as Status__c and one approval process is there on Opportunity.Now assume one associated Opportunity record is under the approval and If approver tries to approve opportunity record, And if status__c on Account is as blank then it should throw an error message that should be visible to approver on his system screen.  So this situation cannot be handled using Admin Validation Rules and we handle at code level using a trigger.

Ajay K DubediAjay K Dubedi
Hi Anitha,
Validation Rule: Validation rules verify that the data a user enters in a record meets the standards you specify before the user can save the record. Validation rules also include an error message to display to the user when the rule returns a value of “True” due to an invalid value.
Eg: A very basic validation for start date and end date, a start date cannot be greater than the end date, this can be handled using the validation rule, where you specify the formulae as (StartDate > EndDate) - Display Error ("Start Date cannot be greater than End Date"). Your record will not be saved unless your formulae become false.
Validation rules apply to new and updated records.
You cannot perform any DML operation and many other things that a trigger can do.
Trigger: Apex triggers enable you to perform custom actions before or after changes to Salesforce records, such as insertions, updates, or deletions. A trigger can be used to perform some update on the same record or a related record based on some business criteria, can be used to perform DML operation on other records that meet some business criteria, can be used to send an email, invoke a future HTTP callout, etc.
Eg: A typical use of trigger would be to say update a contact field on Account, whenever a new Contact is inserted. To meet this requirement, you will write a trigger on contact, which will perform an update on the associated Account.
At the end it would depend on your actual requirement, just to check if the data entered is valid, use validation rule, to perform other complex business operations, use the trigger.
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Ajay Dubedi