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
Vserv CapitalVserv Capital 

i want intigrate salesforce to facebook by leadcapture app

I write a class leadhelper
public class LeadHelper {
     public static void createContact(List<Lead> leadList){
        Id ContactRecordTypeId =  Schema.SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('New').getRecordTypeId();
        List<Contact> listAcc=new List<Contact>();
        for(Lead l : leadList){
            Contact acct = new Contact();
            acct.firstName = l.firstName;
             acct.LastName = l.lastname;
            acct.Email = l.Email;
            acct.MobilePhone = l.MobilePhone.Substring(2,l.MobilePhone.length());
            acct.RecordTypeId = ContactRecordTypeId;
            acct.Source__c = 'Facebook';
            acct.Project__c = l.Project__c;
            acct.BillingCity__c = l.City;
            acct.Ad_Name__c = l.Ad_Name__c;
            listAcc.add(acct);
        }
        system.debug('listAcc : ' + listAcc);
        insert listAcc;
    }
}


Write trigger 

trigger LeadTrigger on Lead (after Insert) {
    if(Trigger.isInsert && Trigger.isAfter){
        LeadHelper.createContact(trigger.New);
    }
}

But lead not insert
ANUTEJANUTEJ (Salesforce Developers) 
Hi Vserv,

Try checking if you are getting the leads in and also try checking it and if the trigger is deactivated are the lead records are getting created?

Looking forward to your response.

Thanks.
Vserv CapitalVserv Capital
now  deactivate a trigger  but lead not capture