[SalesForce] Custom Buttons conditional display

Is there a way to conditionally control the display of custom buttons? To be more precise, let's say I have a button which should be visible only if Field1==X. If the button is added to a page layout, it would appear at all times, which is not quite good from the user perspective as it clutters the GUI and diminishes speed of decision making.

I'm familiar with two work-around approaches, but none of them suit my needs. First one is embedding a VisualForce page containing only buttons in the page layout, and in the VF page controlling buttons' appearance through standard SFDC mechanism (components with rendered attribute conditionally set). Second one is a work-around I came across just recently, and it involves a formula field emulating the functionality of a button.

But both of these approaches result in custom buttons being placed either in a separate section (approach #1 with VF page) or in the fields section (approach #2). What I would like to achieve is have the conditionally controlled custom buttons appear in line with the standard ones, just like the 'regular' custom buttons.

Best Answer

While I have not actually implemented this myself, Jason Venable (AKA TehNrd) submitted a solution for a contest with CloudSpokes a while back. It addresses this very issue. Looks like a very cool solution to the problem.

Like I said, I haven't tried to implement this solution, but I have in the past used some stuff from Jason's blog and always find it to be excellent and useful.

I would take a look

http://www.tehnrd.com/show-and-hide-buttons-on-page-layouts/

Related Topic