You need to sign in to do that
Don't have an account?
Afrose Ahamed
Lead Convert - How to check existing Account choosen or new Account When lead convert using trigger
Hello All,
When a lead is converted, is it possible to find out, in an Apex trigger, whether the ConvertedAccountId is referecing to an existing Account or an Account created as a result of the conversion? Or in another word, can I find out whether a user selected an existing account or created a new account as part of the lead conversion process?
Thanks,
Afrose Ahamed
Try Below Code Please Mark It As Best Asnwer If It Helps
Thank You!
All Answers
A similar ask is posted here https://salesforce.stackexchange.com/questions/13047/is-there-a-way-to-determine-how-certain-account-has-been-created
Copying relevant text:
Have a checkbox field on the Lead, Was_Lead__c (default: checked) that maps to a field on the Account. This value can be carried over on Lead conversion. If you need to trace it back to the original Lead, you could probably use a formula that provides the Lead's ID field. To configure this, go to
Setup | Customize | Leads | Fields
and look for theMap Lead Fields
button in the Custom Fields section.You could do a SOQL query on your closed Leads. The following query will provide you a list of all Accounts and Contacts that originated from a converted Lead. You could filter it on specific Account Ids, if necessary.
Get all converted Accounts and Contacts:
Find the original Lead for a specific Account:
If this information helps, please mark the answer as best. Thank youTry Below Code Please Mark It As Best Asnwer If It Helps
Thank You!
Hi @CharuDutt,
I copied your code and pasted in my org. but im getting error oldMap variable does not exist. Can you please help,
Regards.
Afrose Ahamed M.G.
It Should Be Like This " !Trigger.oldMap.get(oLead.Id).IsConverted"
Hi @CharuDutt,
Thank you so much working as expected.....