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
KnowledgeseekerKnowledgeseeker 

How do I Add the "Delete" Button for System Administrator Profile only?

How do I code/add the "Delete" button to standard objects (Accounts/Opportunities) for my custom Visualforce pages. So that it restricts the delete button to only System Administrators, which is what we had prior to going live with the custom Visualforce pages.

 

Currently it is setup that no Profiles can see the "Delete" button, i only know how to make either all Profiles see the "Delete" button or All Do not see the "Delete" Button.

 

Any help is greatly appreciated!! Thank you in advance!

 

- Jeremy

 

PratzJPratzJ

One solution is to create 2 VF Pages

1) With Delete Button

2) Without Delete Button

 

The System Admin Profile should be able to see on the VF page with Delete Button. All other profiles would see the VF page wihout Delete Button.

 

Another Solution is restrict the permission to Delete the Record to Non- System Admin users using Profile Permissions that way, the users will still be able to see the Delete Button but won't be able to delete the record.

PratzJPratzJ

One more solution:

In the VF page check the Profile of the Logged In user using $User.Profile==Administrator and make the button visible only fi the condition is true.

Let me know if that helped

KnowledgeseekerKnowledgeseeker

This sounds like it could be the best answer. Would you mind describing how to do this specificly (i.e. step-by-step, screenshots) or could we possibly do a quick Webex?. Solving this is extremely important to myself and our org. Further assistance is greatly appreciated. Let me know, if you could, Thank you PratzJ  - Jeremy

KnowledgeseekerKnowledgeseeker

Just to be clear on my last post...the solution I'm refering to is below (the one i'd like clarified)

 

"One more solution:

 

In the VF page check the Profile of the Logged In user using $User.Profile==Administrator and make the button visible only fi the condition is true.

 

Let me know if that helped."

 

THANK YOU