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
itdeptitdept 

Overriding the convert button on lead using Visualforce

I have a situation where I'd like to solve using Visualforce, but i think it's do-able with Javascript as well.  Here's the situation:

We have a couple of different record types for Leads, record type A, and record type B.  Each record type is for a different process.  We need the "Convert" button for the Lead object to have the "create opportunity" checkbox CHECKED if the lead being converted is of record type A.  We need to have the "create opportunity" checkbox UNCHECKED if the lead being converted is of record type B.  How can I override the "Convert" button using Visualforce?  I'm sure Visualforce can handle conditionals and redirect the url to the right location...

Thanks in advance!
-Frank
sfdcfoxsfdcfox
You have two basic choices. You can either (a) create a Visualforce page to maintain the entire process, or (b) create a Visualforce page that will redirect with the appropriate values set.

<pre>
<apex:page standardController="Lead">
<script>
if({!Lead.RecordType.Name="RecordTypeA"}) {
    window.top.location.href = "/lead/leadconvert.jsp?nooverride=1&id={!Lead.Id}&nooppti=0"; // 0 clears the box
} else {
    window.top.location.href = "/lead/leadconvert.jsp?nooverride=1&id={!Lead.Id}&nooppti=1"; // 1 checks the box
}
</script>
</apex:page>
</pre>