+ Start a Discussion

Lead is converted then how to prevent the account and contact records creating

i created BulkTrigger for Lead Conversion.i created two custom objects. i.e   Agency and Broker objects.

i. Now Lead is Converted then  Lead company name goes to Agency and Lead Name goes to Broker object. that's working fine.

ii. once lead is converted Salesforce automatically created account and contact records.But we Need to Prevent the Account and Contact inserting. .is it possiable. ...............Pls Help me...........................


User Manually Lead Records converted using Convert Button in Lead home page.




trigger ConvertLead on Lead (after insert, after update) {
    List<Lead> leadIds = new List<Lead>();
    Id lId;
  for(Lead led: Trigger.New){
        if(led.isConverted == true && led.Lead_type_picklist__c =='Broker'){
            if(led.id != null)
    Map<Id,Lead> leadMap = new Map<Id,Lead>([Select id,Name,Company from Lead Where id in:leadIds]);
    List<Agency__c > agencyinsert = new List<Agency__c >();
    List<Broker__c> brokers = new List<Broker__c>();
    for(integer i=0; i<leadIds.size(); i++){
        lId = leadIds[i].Id;
        Lead leadobj = leadMap.get(lId);
        Agency__c ag = new Agency__c();
    if( agencyinsert.size()>0)
        insert agencyinsert;
   for(integer i=0; i<leadIds.size(); i++){
      for(integer j=0; j<agencyinsert.size(); j++){
             Lead leadobj1 = leadMap.get(lId);
             Broker__c b = new Broker__c();
             b.Name = leadobj1.Name;
             b.Agency__c = agencyinsert[j].id;
     if(brokers.size() > 0)
        insert brokers;


How can Prevent the inserting account and contact records once lead is conversion.pls help me...............................


You'd want to look at overriding the Convert button on the Lead object.

App Setup > Customize > Leads > Buttons and Links

You have the option of overriding the behaviour with an S-Control or Visualforce page, so you may need to alter things slightly.