2

Just started to work with the lead conversion.

What's the most accurate method to identify which lead is an opportunity/contact/account converted from?

Thanks

0

3 Answers 3

0

Create a calculation on the Lead that is equal to LeadId for each field that you want to map - ie Opportunity_Lead_Id__c and Account_Lead_Id__c.

Then create similar fields on Opportunity and Account - Just call them From_Lead__c or Lead_id__c.

Then map them in the lead mapping area.

Note - you need a separate calc field on Lead for each field that you want to map, that's why you'll need three similar fields on the lead to map to Account, Contact and Opportunity.

6
  • Thanks, this is the method I am thinking but 3 same fields on lead made me hesitated to proceed.
    – sfdcnoob
    May 13, 2015 at 21:37
  • Right now, I can't think of another way, but I'm having a wee look to see if there are any other techniques out there. May 13, 2015 at 21:41
  • Take a look at my other answer - I reckon it's better in some cases, if you feel like writing some code May 13, 2015 at 21:57
  • Use the fields that salesforce.com gave you!
    – sfdcfox
    May 13, 2015 at 22:36
  • Are these fields present already? :/ May 13, 2015 at 22:42
2

You don't need to do anything special, as this data is automatically linked for you. Leads, once converted, have three fields populated: ConvertedContactId, ConvertedAccountId, and ConvertedOpportunityId. You can run reports and SOQL queries on those leads to see which lead the account/contact/opportunity came from. You get this for free. There's even a Lead with Converted Lead information report you can run out of the box.

6
  • So I am able to fetch these data from the after update trigger of lead after the lead is converted. Thank you for much
    – sfdcnoob
    May 13, 2015 at 22:39
  • Actually, this data is stored on the Lead, not the Opp, Contact and Account. It's handy to have it on those records, so I think my answer stills stands. May 13, 2015 at 22:47
  • I'd probably add three fields and a mapping over adding stuff to a trigger that you need to write unit tests for. May 13, 2015 at 22:50
  • @CaspNZ Sure, it depends on the use case, but ordinarily, you don't care about the lead much afterwards so much as "during" the conversion, in which case, you'd ordinarily want to just do so in the Lead's AfterUpdate trigger event.
    – sfdcfox
    May 13, 2015 at 23:16
  • Good point. I was going to remove the answer, but I feel it has some value now... On the other hand, the fact that these fields exist is great to hear and has a lot of value too. Probably more. :) May 13, 2015 at 23:26
0

Ok, here's another way. You can override the convert lead button and redirect to your own VisualForce page.

Essentially, in the page controller, you will call something like this:

Database.LeadConvert lc = new database.LeadConvert();
lc.setLeadId(lObj.Id);        
lc.setConvertedStatus(convertStatus.MasterLabel);               
Database.LeadConvertResult lcr = Database.convertLead(lc);

Id oppId = lcr.getOpportunityId();

Once you have that, you can query for the opportunity and set whatever fields you like. The same applies for Accounts and Contacts

These methods are available on the LeadConvertResult:

getAccountId() 
getContactId() 
getErrors() 
getLeadId()
getOpportunityId() 
isSuccess() 
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .