+ Start a Discussion
Jim F.ax281Jim F.ax281 

How to show/hide custom buttons on related lists

Hi all,
I've got a related list on my Opportunity page layout.  It has a custom button on it with OnClick javascript.  I want the button to be visible only if the Opportunity.StageName = 'Closed/Won'.  I've done this using a VisualForce page on the layout that hides the button, but this seems incredibly kludgy.  Does anybody have a better suggestion?
Thanks, Jim
Boom dev9xBoom dev9x
Hi Jim,

I think I have one suggestion but I'm not sure if it is any better than the VF page (well, at least this will use all the standard funcationality). You will need:
- Record types on the Opportunity object (i.e. "Open" and "Closed/Won")
- 2 page layouts. One for the open record type and the other for the closed/won record type. On the closed/won page layout you can hide the button
- A workflow rule that change the record type from open to closed/won when the opportunity stage is "Closed/Won"

Jim F.ax281Jim F.ax281
Hi Boom,
That's a good idea, but unfortunately not in my case.  I need to be able to do this without creating any new opportunity page layouts, just add to existing page layouts.  I guess I should have mentioned that earlier... :)
Thanks, Jim
Sagar PareekSagar Pareek
Hi Jim,

There are only two possible ways to achieve this

1.Custom Buttom with javaScript
2. Two Record Types 

The first one you have already tried out.
Robert ZentgrafRobert Zentgraf
Hi Jim,

you can add some js to the button, so that the user receives an information, that this button is only working on Stage Closed/Won.
It could be something like:
if (stage != 'Closed/Won') {alert('This is not working in this stage')} else {*here you can add your code*})


(mindforce: http://www.mind-force.de)