Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers 2

up vote 2 down vote accepted

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/

share|improve this answer
    
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 –  Martin Borthiry Feb 18 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_zg Feb 19 at 11:31
add comment

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.

share|improve this answer
    
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_zg Feb 19 at 11:38
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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