You need to sign in to do that
Don't have an account?

Automatically create account, opportunity and contact after incoming lead from the app exchange
Hello
Automatically create account, opportunity and contact after incoming lead from the app exchange
We are using custom objects for opportunity. We receive Leads in our system, when someone saves our app from the AppExchange.
We would like to convert immediately this leads to account, contact and opportunity (custom object).
Any ideas how to achieve this?
Thanks
Petya,
Please find below a sample code which you can expand upon.
for(Lead mylead : Trigger.New){
Database.LeadConvert lc = new database.LeadConvert();
lc.setLeadId(mylead.id);
LeadStatus convertStatus = [Select Id, MasterLabel from LeadStatus where IsConverted=true limit 1];
lc.doNotCreateOpportunity=false;
lc.setConvertedStatus(convertStatus.MasterLabel);
Database.LeadConvertResult lcr = Database.convertLead(lc);
}
All Answers
You will need Apex coding for this requirement.
An Apex trigger on the Lead object that would leverage the Database.LeadConvert class for the Account and Contact creation:
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_dml_convertLead.htm
As you use custom objects for opportunities, you would need to build another method for the Lead -> custom object conversion.
Petya,
Please find below a sample code which you can expand upon.
for(Lead mylead : Trigger.New){
Database.LeadConvert lc = new database.LeadConvert();
lc.setLeadId(mylead.id);
LeadStatus convertStatus = [Select Id, MasterLabel from LeadStatus where IsConverted=true limit 1];
lc.doNotCreateOpportunity=false;
lc.setConvertedStatus(convertStatus.MasterLabel);
Database.LeadConvertResult lcr = Database.convertLead(lc);
}
thank you very much! I will check this