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
Shubhangi JadhavShubhangi Jadhav 

validation on delete button

Hi,

Anyone can help me to write trigger on order.
other than admin no one should be able to "delete" order.
Thank you.

Regards,
Shubhangi
SwethaSwetha (Salesforce Developers) 
HI Shubhangi,
You can try the below trigger to see if it works
Trigger PreventDelete on Order(before delete){

Id profileid=[Select Id,Name from Profile where Name ='System admin'].Id;
   if(userinfo.getProfileId()==profileid){
      // bypass the restriction
    }
   else{
            Trigger.old[0].addError('This record cannot be deleted');           
    }
}
Related: https://salesforce.stackexchange.com/questions/162598/trigger-to-prevent-deletion-of-tasks-or-attachments-except-for-admins

https://salesforce.stackexchange.com/questions/132012/trigger-to-prevent-account-deletions#

https://developer.salesforce.com/forums/?id=906F0000000MGq1IAG

Hope this helps you. Please mark this answer as best so that others facing the same issue will find this information useful. Thank you