You need to sign in to do that
Don't have an account?

Show/Hide a button on a standard page
Hi,
I found the same question that was posted back in 2007; however, there was no answer to the question so I decided to ask again.
Is there a way to hide or show custom button on a standard page based on a condition. In my case I want the button only to show if a system administrator is logged in, all other users should not see this button as it would be used to do some adminstrative work such as call a VF page/controller.
I found the same question that was posted back in 2007; however, there was no answer to the question so I decided to ask again.
Is there a way to hide or show custom button on a standard page based on a condition. In my case I want the button only to show if a system administrator is logged in, all other users should not see this button as it would be used to do some adminstrative work such as call a VF page/controller.
You create a page layout for the users and one for the system admins.
You remove the button from the page layout for the users.
You show the appropriate page layouts to the appropriate profiles via page layout assignment
There is a method available to accomplish what you want. "UserInfo.getProfileId()" you can use this method into your constructor and you have to check the user's profile(whether it is admin or not).
For more info pls refer the below example.
Example:
string pf=UserInfo.getProfileId();
Profile p=[select Name from Profile where Id =:pf limit 1];
if(p.Name=='System Administrator')
{
// using rendered to show/hide button
}
Your suggestion looks like it is apex code that would be in a controller connected to a VF page; however, I am asking about a custom button on a standard page. Or am I just not understanding your suggestion and if so please provide me more feedback? I want to hide a button on a standard page. If that is not possible then I may have to settle for Starz26 suggestion as I don't think the users would want to see a button on their page that is really an administrator's button.