You need to sign in to do that
Don't have an account?
Vserv 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
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
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.