• Vserv Capital
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 3
    Replies
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;
    }
}
 
public class LeadHelper {
        public static void createContact(List<Lead> leadList){
        Id ContactRecordTypeId =  Schema.SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('New').getRecordTypeId();
        List<Contact> listCo=new List<Contact>();
        for(Lead l : leadList){
            Contact Con = new Contact();
            Con.firstName = l.firstName;
            Con.LastName = l.lastname;
            Con.Email = l.Email;
            Con.MobilePhone = l.MobilePhone.Substring(2,l.MobilePhone.length());
            Con.RecordTypeId = ContactRecordTypeId;
            Con.Source__c = 'Facebook';
            Con.Project__c = l.Project__c;
            Con.Address__c = l.Billing_City__c;
            Con.Ad_Name__c = l.Ad_Name__c;
            listCo.add(Con);
}  
     system.debug('listCo : ' + listCo);
        insert listCo;

            
      }
}


Please help me how can write test class code
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> listCo=new List<Contact>();
        for(Lead l : leadList){
            Contact Con = new Contact();
            Con.firstName = l.firstName;
            Con.LastName = l.lastname;
            Con.Email = l.Email;
            Con.MobilePhone = l.MobilePhone.Substring(2,l.MobilePhone.length());
            Con.RecordTypeId = ContactRecordTypeId;
            Con.Source__c = 'Facebook';
            Con.Project__c = l.Project__c;
            Con.Address__c = l.Billing_City__c;
            Con.Ad_Name__c = l.Ad_Name__c;
            listCo.add(Con);
}  
     system.debug('listCo : ' + listCo);
        insert listCo;

            
      }
}


Please help me how can write test class code
The code below is facebook  integration code in salesforce . I want to download likes ,comments and posts in salesforce and then i want to see it in Visual force page .
Kindly   solve this code.
To see post  --change the url  ------ https://graph.facebook.com/me/feed?
Http http =new Http();
HttpRequest req =new HttpRequest();
req.setEndpoint('https://graph.facebook.com/me/feed?access_token=Edkjghkdjhkhghdkghkh');
req.setmethod('GET');
HttpResponse res = http.send(req);
String str = res.getbody();
System.debug(str);