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.

2 Answers 2


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


  • Excellent idea to have a sidebar component. I never could solve the cross site restriction when I tried to add a similar javascript using a VF component on the pagelayout Feb 18, 2014 at 14:58
  • Quite innovative approach, although still not what I was looking for :) I was hoping to come across a solution that would be somewhere on the lines of formula conditions: success.salesforce.com/ideaView?id=08730000000abxDAAQ Still, I'm gonna go with your answer as it added something new to my workarounds pool :)
    – dino ursic
    Feb 19, 2014 at 11:31
  • Your link is no longer active. Perfect example of why we need to include relevant content!
    – Adrian Larson
    May 12, 2016 at 15:30
  • You can find the original article archived on the Wayback Machine: web.archive.org/web/20131115070952/http://www.tehnrd.com/… Apr 12, 2017 at 15:05

Two ideas to add to the mix:

1) This seems like a classic use case for record types . Using different record types would allow you to allocate different page layouts and so use different buttons at the top.

It may seem pretty full on, but if objects require different processes based on field values, this is kind of the point of record types.

2) Another idea is to create an entire VF page override for the view page, which could include the standard detail for the object and related lists using simple VF tags, but then you could add a custom section at the top to add your own buttons, rendered depending on the field property.

I hope that helps.

  • 1
    Hi Christopher, thanks for the effort. But I wouldn't quite agree that using different record types should be used here. Let's say you have opportunity with discount < 10% and opportunity with discount > 10%. One with the lower discount does not require special approval, while the other one does. From my perspective to small difference to be considered different record types. As for the second idea, yep, that could work, but in the current situation I'd say a bit daunting for the large page layout I have to deal with.
    – dino ursic
    Feb 19, 2014 at 11:38
  • Hi @christopheralunlewis, I checked with record types, we don't get option for setting field value for record types.. Please guide me how to achieve this?
    – Sanjivani
    Mar 12, 2015 at 7:53

You must log in to answer this question.

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