function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
benderguybenderguy 

How to hide/show (custom lead convert) button based on field value using visualforce WITHOUT apex?

I want a button to convert a lead to appear on a standard lead page layout, but only under certain conditions.  I'm trying to come up with a next-generation way of doing this so that I don't have to create multiple record types and page layouts whose only difference is whether a single button appears (and logic to drive switching record types, etc.).  I'm (obviously) new at VF, but perhaps this example can help others as well.

 

I've tried to create a simple visualforce page that I can include on a standard layout.  The page/button appears once I add it to a layout, but it's pretty difficult finding references to exactly how the related button syntax is supposed to work.  My example is below.

 

<apex:page StandardController="Lead" id="ConvertButton">
<apex:form>
<apex:commandButton action="/lead/leadconvert.jsp?retURL=/{!Lead.Id}&id={!Lead.Id}" value="ConvertIt" disabled="{!IF(Lead.Application_Complete__c, 'true', 'false')}"/>
</apex:form>
</apex:page>

 (I have a checkbox called "Application Complete" on the Lead object.)

  1. Is there a standard lead action I can use or do I have to build my own button with my own URL?  I can't find any reference to how to make {!Action.Lead.Convert} work here, for instance.  Is that possible?  It seems like it should but no matter what I try I get a message like "Error: Unknown method 'LeadStandardController.Convert()' " when I try to save the VF page.
  2. How do I get the URL to launch a new page?  When clicking on the button all I get is a page launched within the tiny space where the visualforce page is inserted into the standard layout.  I can't find a reference as to how to make it launch into a full new page.
  3. I can't seem to get the IF statement to work properly.  It doesn't generate an error when creating the visualforce page, but it doesn't disable/enable the button properly either.  I also tried using "NOT", but without success.  Can someone provide an example of how to make these logical functions work properly in this situation?
  4. I'd like to see this example work (if it is possible) in order to understand VF better, but if there is a better way to achieve my goal I'd also like to hear it.

 

 

Message Edited by benderguy on 05-01-2009 09:23 AM
Message Edited by benderguy on 05-01-2009 09:24 AM