You need to sign in to do that
Don't have an account?
LeadConvertResult.getContactId
Hi All,
I have written some custom Apex code the converts leads into accounts, opportunities and contacts. After converting, we updated some custom fields inside the converted contact and opportunity.
I'm having a problem with the LeadConvertResult.getContactId. Something must have changed, as this code worked, and the unit test I have used to pass in this case, but it's failing now.
Database.LeadConvertResult lcr = Database.convertLead(lc); if(lcr.isSuccess()){ Account acc = [select id, name, bd_manager__c, Account_Executive__c from account where id = :lcr.getAccountId()]; Contact convertedContact = [select id from contact where id = :lcr.getContactId()]; ...
The first line after lcr.isSuccess works fine: I can see the account just fine. Unfortunately, the second line (getting the convertedContact) does not. It seems lcr.getContactId returns null, and thus we cannot do anything with the convertedContact. Afterwards, when I manually look at the converted lead, it shows the properly converted contact.
Has anyone else seen this behaviour? Do I have to do anything different to retrieve the converted contact?