function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
toddmcgrathtoddmcgrath 

convertLead to an existing PersonAccount: error - cannot associate a contact with a consumer account

Hello,

 

I'm trying to convert a Lead to an _existing_ Person Account using convertLead.

 

Any ideas on what

 

cannot associate a contact with a consumer account

 

 means?  According to docs, I should set contactId to null which I'm doing.

 

 

public LeadConvertResult[] convertLead (ID leadId, ID contactId, ID accountId, boolean overWriteLeadSource, boolean doNotCreateOpportunity, String opportunityName, String convertedStatus, boolean sendEmailToOwner, ID ownerId) {

LeadConvert leadConvert = new LeadConvert();

// set to null when converting to an existing person account
leadConvert.setContactId(null);

leadConvert.setOwnerId(ownerId)
leadConvert.setAccountId(accountId);

leadConvert.setLeadId(leadId);
leadConvert.setOverwriteLeadSource(overWriteLeadSource);
leadConvert.setDoNotCreateOpportunity(doNotCreateOpportunity);
leadConvert.setOpportunityName(opportunityName);
leadConvert.setConvertedStatus(convertedStatus);
leadConvert.setSendNotificationEmail(sendEmailToOwner);
ConvertLead convertLead = new ConvertLead()

convertLead.setLeadConverts([leadConvert] as LeadConvert[])

ConvertLeadResponse response = serviceStub.convertLead(convertLead, sessionHeader, null, null,null,null )
LeadConvertResult[] lcr = response.getResult()
//lcr is returning "cannot associate a contact with a consumer account" error
return lcr

}

 

 

When code calls convertLead with a Account/Contact combo everything works _fine_, so I'm having issues with convertLead and Person Accounts only.   

 

Shouldn't this be working?  

 

Any ideas, suggestions, greatly appreciated.

 

Todd

 

 

 

Message Edited by toddmcgrath on 10-01-2009 03:33 PM
Message Edited by toddmcgrath on 10-01-2009 04:06 PM
Best Answer chosen by Admin (Salesforce Developers) 
toddmcgrathtoddmcgrath

In hopes it saves some agony, the solution is not in the convertLead call as much as it is the Lead field values.

 

See:

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_lead.htm

 

So, if the lead company field is null, then convertLead call (with null accountid and contactid) will create a Person Account.  This will be the solution for me.

 

 

All Answers

SuperfellSuperfell
the accountId you've specified refernces a person account, not a business account, only business accounts can have contacts asociated with them.
toddmcgrathtoddmcgrath

Thanks for reply, Simon. 

 

Have to admit, I'm confused though.

 

How do we use convertLead with Person Account?

 

I found this in the docs:

 

"If person account record types have been enabled and if the value of the Company field is null, the lead converts to a person account. See “Notes on Converting Leads” in the Salesforce.com online help."  

 

So, I'm setting contact to null thinking that would be the trick.

 

Thoughts?  What am I missing? 

 

toddmcgrathtoddmcgrath

The following is also in the docs for convertLead:

 

"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."

 

 

I can successfully call convertLead with:

 

1) null accountid and contactid which creates new account/contact

2) an existing accountid and contactid 

 

I need to know how to convertLead with a Person Account.  The aforementioned error doesn't make sense to me.

 

Any ideas?  Suggestions?

toddmcgrathtoddmcgrath

In hopes it saves some agony, the solution is not in the convertLead call as much as it is the Lead field values.

 

See:

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_lead.htm

 

So, if the lead company field is null, then convertLead call (with null accountid and contactid) will create a Person Account.  This will be the solution for me.

 

 

This was selected as the best answer