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
Abhi LakshayAbhi Lakshay 

Custom lead conversion based on record types

Hi All
We are trying to create a custom process for Lead where by a "convert" button on, say, Record type 2 will convert a lead to an affiliate(custom object) record ONLY and not create Account, Contact and Opportunity (The standard lead conversion process to remain same for lead record type 1)). What all would I need? 
I can create a on click JS for the button to call the apex. Would I need to create an apex class or a trigger? Would I also need to have a custom controller for lead ? 
P.S: A beginner in Apex world here. More information the better
Thanks!!
Mohan ChanderMohan Chander
Hi Abhi,

Create 2 RecordTypes on Lead and let the Standard Convert Lead button Stay on the Page Layout for RT1 and now for the RT2 hide the Standard convert Lead button replace that with Custom Convert Lead button.

Now on click of this custom button invoke apex and create whatever object you want to create and redirect the user to that newly created record. You can refer to the below example 
https://andyinthecloud.com/2013/07/16/how-to-call-apex-code-from-a-custom-button/

Let me know if this helps.
 
Abhi LakshayAbhi Lakshay

Hi Mohan

Even if we do that, wouldnt the 'database.convertlead' still run at the backend and still create account, contact and opportunity?

If yes, Is there a way to NOT create any of these objects on conversion?