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
Jazmine MooreJazmine Moore 

Overriding "Delete" with Visualforce Page for only non System Admin Profile Users.

I am looking to override the Delete button and link on both the contact and lead objects.  Can anyone help me with the Visualforce page and controller class?  
v varaprasadv varaprasad
Hi Jazmine,

Create a new record type and remove that button in page layout and assign that record type to all profiles except admin.


Hope this helps you!
If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others.


Thanks
Varaprasad
Salesforce Freelance Consultant/Developer/Administrator
@For Salesforce Project Support: varaprasad4sfdc@gmail.com


Salesforce latest interview questions  :
https://www.youtube.com/channel/UCOcam_Hb4KjeBdYJlJWV_ZA?sub_confirmation=1

 
Puneet KhoslaPuneet Khosla
For overriding the button, the only thing you need to consider is writing standardcontroller="Object Name" in VF apex:page tage  and override the delete button with the VF page. If you only want to do it for certain profiles, then you will have to check that in the apex class.

For more help, you can actually refer to the following post where a similar problem is addressed (though its based on field and not profile)
https://developer.salesforce.com/forums/?id=906F0000000971PIAQ
Jazmine MooreJazmine Moore
Thank you. I know that page layout would be a solution for hiding the Delete button, but I'm not able to take away the Delete links in the list view, or related views.