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
nagarjuna gurajanagarjuna guraja 

Need Apex Trigger And ValidationRule

Hello All,
1.Write a trigger to prevent user from editing record(If any field is edited) on Account Object.
2.Write a Validation rule  to prevent user from editing record(If any field is edited) on Account Object
Best Regards,
AnkaiahAnkaiah (Salesforce Developers) 
Hi Nagarjuna,

Can specify the criteria, when user should not edit the account record.?

Thanks!!
nagarjuna gurajanagarjuna guraja
If any field is updated or deleted,then it should prevent user to modify record
AnkaiahAnkaiah (Salesforce Developers) 
Hi Nagarjuna,

try with below validation rule.
NOT(ISNEW())
Try with below trigger.
 
trigger preventAccountDeletion on Account (before delete) {

    for(Account acc : trigger.old){
        acc.adderror('Account Cannot be deleted');
    }

}

If this helps, Please mark it as best answer.

Thanks!!​​​​​​​