I have one custom detail button in the Account page ,i want to hide that button based on the user profile ? Is there any way we can do this?


Create a new Page layout and remove that button from it. Assign that page layout to the Profile to which you don't want to show the button.

  • 1
    Is that any other solution without creating the page layout? – SUresh Shettigar Apr 26 '16 at 14:08
  • 1
    Not that I know of. – Sf_Noob Apr 26 '16 at 14:10

To do what you're asking about you'd need to create a Dynamic Visualforce Component based on the $User.Profile:

Modified from an example in the documentation:

Component.Apex.OutputText renderButton = new Component.Apex.OutputText();
renderButton.expressions.value = 
    '{!IF($User.Profile == "NameofUserRequiredProfile", "True", "False")}';

In the above, you'd want to use this type of thing to use to determine whether or not to render the button based on the value of the Profile matching a specific profile where it can be displayed with it not being visible to any other profile. You could modify it accordingly to do the inverse, render the button for everyone except for that specific Profile too, which I believe is closer to what you're asking to do.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.