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
smagee13smagee13 

APEX Class or Trigger, copy Lead Record

Hello all,

I am trying to either write a trigger or an APEX class that will copy a lead record into a custom object I have called Candidates. 

 

We installed the lab force.com application called Recruiting and will be using this to track employment candidates at my organization.  What I would like to do is use the Web to Lead functionality to capture candidates information from our public site as a special lead record.  Then have a trigger or class take that lead record and insert a new record, using all the lead fields, into a custom object called Candidates.

 

Do any of you out there know if this is possible, have any code samples or done anything like this?

 

Thanks for your help.

 

 

navneetnavneet

sure , it is possible. when you capture all the leads from web and stored then in to lead object you need to write trigger on lead (after insert).

 

 code-

 

trigger trgName on Lead(after Insert) {

 

List <Lead> leadsList = trigger.old;

List<customObj> objList= new List();

customObj obj;

 

for (Lead lead : leadsList){

obj= new customObj();

// map the fields of lead with custom object

obj.FName__c = lead.name; // simillarly 

 

objList.add(obj);

}

 

insert  objList;  // its done

 

 

Let me know incase you face any issue.

 

Regards,

 

Navneet