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
Kondal Rao learnerKondal Rao learner 

regarding about leads

Hi Experts ,

 

please tell me how to do this if possible a sample code.

 

All the rules related to lead conversion and if I wanted to convert lead and after converging lead only create to account. not contact ,how can i achive this ?

 

thanks in advance

Best Answer chosen by Admin (Salesforce Developers) 
hitesh90hitesh90

Hi,

 

Below is the sample code as per your requirement.

 

Apex Trigger:

trigger ConvLeadtrigg03 on Lead (after update) {
    set<Id> sConId = new set<Id>();
    for(Lead mylead : trigger.new){
        if((myLead.status == 'Closed - Converted')){
            sConId.add(mylead.convertedcontactid);
        }
    }
    List<Contact> lstCon = [select id from Contact where id IN: sConId];
    delete lstCon;  
    
}

 

Important :
Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.

Thank You,
Hitesh Patel
SFDC Certified Developer & Administrator & Advanced Administrator & Sales cloud consultant
My Blog:- http://mrjavascript.blogspot.in/

All Answers

hitesh90hitesh90

Hi aditya,

 

You have to write Apex Trigger on lead conversion means (After update) of Lead record.

In this trigger Get convertedcontactId and use DML (delete) operation to delete newly created contact.

 

Important :
Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.

Thank You,
Hitesh Patel
SFDC Certified Developer & Administrator & Advanced Administrator & Sales cloud consultant
My Blog:- http://mrjavascript.blogspot.in/

Kondal Rao learnerKondal Rao learner
thanks for the reply if you dont mind please send me sample code once plese
hitesh90hitesh90

Hi,

 

Below is the sample code as per your requirement.

 

Apex Trigger:

trigger ConvLeadtrigg03 on Lead (after update) {
    set<Id> sConId = new set<Id>();
    for(Lead mylead : trigger.new){
        if((myLead.status == 'Closed - Converted')){
            sConId.add(mylead.convertedcontactid);
        }
    }
    List<Contact> lstCon = [select id from Contact where id IN: sConId];
    delete lstCon;  
    
}

 

Important :
Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.

Thank You,
Hitesh Patel
SFDC Certified Developer & Administrator & Advanced Administrator & Sales cloud consultant
My Blog:- http://mrjavascript.blogspot.in/

This was selected as the best answer
Kondal Rao learnerKondal Rao learner

HI HItesh,

 

Thanks for the reply