You need to sign in to do that
Don't have an account?
Navneeth
Lead to account conversion trigger
Hi i need a Lead Conversion Trigger code. The Trigger should automatically convert the leads to account. It should be an after insert trigger. Since i m new to apex development i am requesting you people to provide me the exact full code.
Also the Exact Skeleton of How the trigger should work is given below.
Please find the exact details/skeleton of lead conversion Trigger on Lead Trigger on lead( after insert) { Get the trigger size (Integer)- take list 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 the values to instance 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
Hey the lead will be inserted from a web to lead form and then the trigger should be able to convert the lead into an account. At present this code is not converting the lead to account.
Please help asap
I tried this code but the lead is not getting converted into account.
I used developer console to check the error.
I got the following error
My logs didn't even show that error, but, in the spirit of being adventurous, I decided I'd try an async method instead:
This worked correctly for Web to Lead. It appears there's some sort of race condition with Web to Lead that prevents leads from being converted directly, so waiting until the Web to Lead transaction completes via @future works.