12

If I want a specific field to be visible only to a specific user or group of users on a layout, I set up field-level security for this field. I want to be able to do the same for my custom button added to a layout. I want a specific button be visible only by a specific group of users.

Is there a way to set a 'button-level' security in order to achieve this? It would be perfect if I could use a permission set.

UPDATE: I know that there were some questions on how to hide a specific button depending on a specific value of an object's field (I already use this solution is another situation), but I want a different thing. I want to be able to specify a permission to see a specific button for a specific group of users.

2

2 Answers 2

14

Buttons don't have a corresponding "button-level" security. There are at least three ways to get around this:

  1. Write a Visualforce page that overrides your default layout. Have that Visualforce page determine if the button should be rendered.

  2. Use page layouts and assign different layouts by profile. Unfortunately, you can't use permission sets this way.

  3. Create a formula field that makes a link to take them to somewhere, similar to the button. Use permission sets to control access to the link via the field level security. Of course, JavaScript is not going to help you here.

On the other hand, if the button links to a Visualforce page, you could just restrict access to the page itself; they'll still see the button, but get an error when they click on it.

12

Sfdcfox' answer looks fine to me, however I have some remarks to point 1. and it is quite an improvement so I decided to not leave it as a comment but as a separate answer, because some people may find it more useful.

The problem with overriding default layout is that it's very hard to maintain - every time you want to add the new field to the object you have to modify the VF code. There's however an alternative:

  • Create custom VF page displaying only a button
  • Make the rendered attribute user-dependent so it only shows to certain users
  • On the standard layout of the object, create a new section at the top with a blank header and put your VF page there

The advantage is you still have the rest of the layout in standard SF, and if the button is not visible, you just have a bit of margin between standard buttons and the rest of the layout.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .