Hi , I need a trigger with certain specific requirements which will help me to convert the leads into an account.
Please note that i will be inserting lead records from a web to lead form.
Once the data is inserted into lead from the web to lead form then the trigger should automatically convert the lead into an account.
Also here is the skeleton of how the trigger should work. Please give me the code since i m new to apex developement.
Please find the details of lead conversion
Trigger on Lead
Trigger on lead( after insert)
{
Get the trigger size (Integer)-
takelist of type <database.leadStatus>---this list is used to hold the leads that needs to be converted
Query the lead Status Isconverted=true(where condition)[ id,Masterlable, should be fetched]
iterate For( i=0;<triggerSize;i++)
{
Create new instance of database.leadconvert
set the following values to instance
set the leadID("id from trigger"),
notCreateOpportunity to(" true")
set convertedstatus(this value from the leadStatus Query)
after setting add it to the list of type<database.leadStatus>-declared at the top
}
//create Database.LeadConvertResult[] array—Shown below [you can use exact line shown below]
Database.LeadConvertResult[] leadResult= Database.convertLead(pass the listOfleads that needs to be converted,false);
//itereate the leadResult and check the system.debug to know the success or failure
Hi maybe you need view this post, could be helpful.
http://sfdevgroup.blogspot.com/2013/04/conversion-de-lead-mediante-apex-code.html
Edgar,