Thursday, 28 February 2019

Lead Conversion – associating with an existing Opportunity


Business Context
There is a very common business scenario where you need to associate your Leads (which are onboarded from multiple sources) /converted Leads to an existing Opportunity. This is a very simple yet a business critical topic.
Salesforce already providing a great capability for Lead Management supporting Lead conversion. In recent upgrade, it has introduced way more user (both Business as well IT) friendly Lead conversion wizard in Lightning along with new method in LeadConvert class. Let’s talk about the possible ways to address this business case, considering this stunning feature.

Solution with new Lightning Lead Conversion feature
As mentioned above, Salesforce now provides a brilliant Lead Conversion Wizard. This allows not only to associate existing Account, it also allows to associate to existing Contacts and Opportunity. On top of it - the beauty is: ‘Enforced Data Governance’ – option for existing Opportunity only available if existing Account is selected, and it will only show selected Account’s Opportunities. Moreover, it leverages standard matching rule for Contact match and Account match while showing matched existing Account, Contact options.





So, for this business scenario, using lightning Lead Conversion wizard is highly recommended since this gives provision to on board Leads and then convert them to existing Opportunity (apart from associating it with existing Account & creating new Contacts or associating with existing Contacts)

Solution with Upgraded LeadConvert Class – useful in Classic
Technically when a Lead is converted, Lead’s ‘IsConvert’ field is set to true, also few other fields are populated e.g. ConvertedAccountId, ConvertedContactId, ConvertedOpportuintyId, above wizard automatically populate those fields as user selects existing Account, Contact, Opportunity. However this wizard is not available in Classic.
Currently Salesforce provides ‘setOpportunityId()’ method in ‘LeadConvert’ Class, which facilitates to set the Opportunity id for the converting Lead. That means, if programmatically Lead is required to be converted, in that case also it can be associated to existing Opportunity. This is very useful in Classic theme as mentioned above Classic does not support this enhanced Lead Conversion Wizard today.

Earlier version of the solution when Lightning Lead Conversion feature or setOpportunityId() was not available
Honestly there was not any such “clean solution” to address this business ask earlier when there was not enhanced Lead conversion wizard or ‘setOpportunityId()’ available. One of the alternate solution options was to have Opportunity lookup configured at Lead level, and then when Lead’s Opportunity is populated by user, a process automation (process builder/flow/trigger) to take place ensuring either Contact creation or identifying matched Contact and then adding it to existing Opportunity’s Opportunity team or do any other actions as per business acceptance.

Considerations to align with this feature
So, with this new feature in place, the existing solution along with its relevant data requires re-evaluation to leverage best of the offerings of the platform. Though completely depends on how you have designed your current solution, there will be Lead data which may undergo some manipulation, but we should remember that for any already converted Lead, you can’t update ConvertedOpportunityId (this might not a valid scenario for your solution).