• Ashutosh Kotha
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

Hi all,

 

I have an issue with convertLead() call. SF keeps returning the same error message once and again : «Specified Contact must be parented by specified Account» whilst I am pretty sure the contact specified is asociated with specified account.

 

The account I specify is business so the rule in APEX API documentation «If you are converting a lead into a person account, do not specify the contactId or an error will result. Specify only the accountId of the person account» does not apply.

 

This is my code:

 

Contact oldestContact = getOldestContact(oldestContactsSOSL));
Lead oldestLead = getOldestLead(leadsEnSF));
LeadConvert lc = new LeadConvert();
lc.leadId = oldestLead.Id;
lc.contactId = oldestContact.Id;
lc.accountId = oldestContact.AccountId;                       
lc.ownerId = oldestContact.Account.OwnerId;
lc.convertedStatus = "Converted";
lc.doNotCreateOpportunity = true;                       
lc.overwriteLeadSource = true;
lc.sendNotificationEmail = true;

LeadConvertResult[] lcr = SalesforceController.instancia.convertLeads(new LeadConvert[] { lc });

if (lcr[0].success)
{
    ...
}
else
{
    ...
}

 

Any comment would be really appreciated. Thanks in advance.

  • November 10, 2009
  • Like
  • 0