Pages

Saturday, August 29, 2015

Salesforce: Track converted Account or Opportunity from Lead

When a Lead in converted into Account, Contact and Opportunity in Salesforce, you can easily track what is the Account and Contact created (or attach to existing Account and Contact), included Opportunity created (if any). By opening the converted Lead in Salesforce, it will show you the Account, Contact and Opportunity name and link, although you will no longer see the Lead detail, except using "Leads with converted information" report.


But, looking from Account, Contact and Opportunity perspective, it is not easy to identify which of them are converted from Lead. However, if you have field history tracking enabled, looking at the object history related list will tell you if the record is created by Lead conversion or not.

Account History

Opportunity Field History

This will be not ideal if you would like to run a report of Account or Opportunity with Lead conversion information, because that information relationship only available in report with type Leads with converted lead information.

Workaround: we can built a simple solution (without code), in this scenario, we would like to report if the Opportunity is created from Lead conversion, and if yes, from which Lead.

1. Create Custom Text Field at Opportunity
Create a custom text field in Opportunity, and make sure with 15 or more characters length.

2. Create a Custom Formula Field at Lead
This formula will return in Text format. The formula would be just a simple Id that will return 15 characters length of the Lead Id, or CASESAFEID(id) to return 18 characters length of the Lead Id.

3. Map Lead Field
From Lead field setup, map custom formula field at Lead to custom text field at Opportunity, this is fields we just created above.

4. Done
Pretty easy, isn't it? From now on, we will be able to tell by running an opportunity report, if the Lead Id is not blank, the Opportunity is created from Lead conversion, otherwise it is not created from Lead conversion.


How to handle if user Clone the Opportunity?
A classic issue that we thought that the Lead Id will be bring over to the new Opportunity cloned, so the Lead Id information is no longer correct. This is only true if we add Lead Id custom text field in to Opportunity page layout.

This mean, Clone function will only clone fields that show in the page layout. By remove that field in the page layout, it will not clone Lead Id. See sample below:



As a double protection to make sure the Lead Id will never be cloned to the new opportunity:
1. Set the text field in Opportunity to 18 characters (for case insensitive Id)
2. Set the text field in Opportunity as Unique and not Case Sensitive
3. Set the formula field in Lead to CASESAFEID(id)

This will protect if in the future, someone build a custom clone functionality, system will throw error by not allowing duplicate Lead Id in Opportunity.



2 comments:

  1. Hello, You have given a very good way to find out about the conversion.
    I have one more question related to it.
    I am working on a trigger on Account where I am restricting users from creating a new account with some conditions. I want to pass this condition if the Account is being created from Lead. Kindly help.

    ReplyDelete
    Replies
    1. create a field and map it to lead convert, but dont show the field in Account page layout

      Delete

Page-level ad