I need to convert Leads into just an Opportunity because for various reasons the Account and Contacts for the Lead record will have been created separately. From the convertLead() docs is seems that if you use this method then you have to create an Account and Contact record on conversion.
Use convertLead() to convert a Lead into an Account and Contact, as well as (optionally) an Opportunity.
Is this correct?
If so, then I would have to create the Opportunity separately which is fine except that I still need to mark the Lead as converted, but I see that the isConverted
field is non-writable.
Would really like to find out about methods to convert a Lead into just an Opportunity and whether I can explicitly set a Lead to isConverted
by code.
Best Answer
Take a look at the documentation:
There you have the ability to provide an existing AccountId and ContactId with the methods setAccountId() and setContactId(), respectively.
You just have to make sure that your contact is associated with the account you provide in AccountId, and if you use PersonAccounts, don't provide the ContactId