+ Start a Discussion
John BraunJohn Braun 

Conditionally show button on a related list?

Hello!

I was hoping I could get an understanding of what options would be available to perform the following function in SFDC:

We would like to be able to conditionally show a custom button on a related list on our opportunity record. The custom button would only display on the quote related list on the opportunity page layout if certain conditions on the synced quote were TRUE.

Here is the catch:

We do not want to create a specific opprotunity record type and page layout for this button to do this action - the reason being that we will need to keep the record type and page layout the SAME and only have the button conditionally show or not show.

Thank you for any help on the above scenario!!
Vamsi KrishnaVamsi Krishna
John,
unfortunately you cannot do much of conditional displays with standard page layouts..  one option i can think of is to show only the related list section using visualforce page component within your standard opportunity page layout.. then in your VF page or in its controller you can check the conditions you need to validate and then show / hide the action buttons...
John BraunJohn Braun
Vamsi,

Thank you for the response -

To clarify the option you suggest -

You are saying that:

1. we would hide the standard view of the quote related list from the opportunity page layouts on all of our opportunity record types
2. create a visualforce page component we could drag onto the standard opportunity page layouts. This visualforce page component would look and function exactly like the standard quote related list
3. this VF page component could have conditional logic that would display the button we want based on data from the syncing quote. However, the opportunity record type and standard page layout assigned to that record type would not be affected


Can you please confirm? Thanks again!!
Vamsi KrishnaVamsi Krishna
Yes John,
you got that right...
if that sounds complex the other option is to move the conditions into your custom button that you want to show on the related list..
you can use On Click Javascript on the custom button and then you can run your conditions in the button' s javascript code which can validate your logic and decide wether it should take the action or return a error message back to the user.. only catch with this approach is the button will be visible all the time..
John BraunJohn Braun
Hi Vamsi,

Thanks again -

Just as a quick test - I'm just trying to tinker with the idea of having the quote related list be a visualforce page component within the standard page layout and not a standard related list - so I'm using this:

<apex:page standardController="Opportunity" tabStyle="Opportunity">
     
        <apex:relatedList list="Quotes" />
  
</apex:page>


And I've dragged it onto my standard page layout.

When I click the buttons in this visualforce component - it opens up the quote edit screen INSIDE the actual iframe/visualforce component. Do you know how to edit it so that when clicking the "Request New Quote" button, it directs the entire web browser window to that target?

User-added image
Vinit_KumarVinit_Kumar
You can try onclick JS function to redirect it to the web browser windows,something like below
<script type="text/javascript">
function Redirect()
{
    window.location.href = "http://google.com";
}
</script>

Now,you can call this function on onClick event of your button.

Another post which could help you to conditional displ.ay of buttons is below :-

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

Hope this helps !!


John BraunJohn Braun
Thanks Vinit,

That seems like it will work for the onclick javascript buttons -

Continuing with the idea that we would "recreate" the quotes related list in this visualforce iframe - what about links clicked that are not standard buttons? For example, the direct link to the quote record itself; how would I make that open up in the parent window and not the iframe? Thanks for all the help!
Vinit_KumarVinit_Kumar
This onClick JS function should do the trick.Have you tried it ??

You should replace the URL where it needs to be redirected with google.com ..