1

On a webservice class i'm creating a Lead and sometimes A contact with the same External ID (UserID from our website) will already exists for multi-companies. What I want to achieve is to generate a new Account (If possible from a lead, since all accounts we create come from promoted leads and this would make things more confusing for sales and BI) that is related to the existing contact using "Related contacts". The problem is that on the ConvertLead class documentation we find this

setContactId(contactId) Sets the ID of the contact into which the lead will be merged (this contact must be associated with the account specified with setAccountId, and setAccountId must be specified). This value is required only when updating an existing contact. So, I can't actually create a new Account but merge the lead into an existing Contact and later relate it to the new account.

There is any way I could do this smoothly without having to schedule deleting any object which seems a pretty rude way to solve this or creating an Account from nothing(without leadID)?

2
  • Please take the time to visit the Help center and read How do I ask a good question. The more details you provide, particularly code you've written, the more likely it is that someone will respond to your question with an answer you'll find helpful.
    – crmprogdev
    Aug 12, 2016 at 14:47
  • 1
    You would have to manually create the account in your web service OR you could convert into a new contact and account and merge the existing contact with the new contact in your web service (The latter being the cleanest I believe)
    – Eric
    Aug 12, 2016 at 14:51

1 Answer 1

1

The cleanest way would be:

  1. Convert the lead into a new contact / account (resolving any duplicate detection issues)
  2. Merge the existing contact with the new Contact.
3
  • And How could I from Apex Add a relation to the contact with the 2º Account? I'm trying to find info about that object but I find nothing related to inserting new Relations to contacts by code. Aug 12, 2016 at 15:54
  • I am not sure what you mean here. But if you have the original contact ID, once you convert the lead you can get the converted contact ID. Then you can merge the two via apex.
    – Eric
    Aug 12, 2016 at 17:58
  • Nah it was a pretty dumb question, I just have to insert a new AccountContactRelation relating the new Account created and the Contact ID after the merge and I'll be ready to go. Aug 16, 2016 at 9:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.