I have some code that automatically converts leads when certain conditions are met using the convertLead() method. This process is fairly well-documented in threads such as this:

Convert Lead on Update trigger

and this works just fine for the most part. However, I'm noticing some strange behavior regarding the owner the newly created contact. For a brief moment in time, the owner of the contact that results from the lead being converted is the user that causes the trigger to fire rather than the owner of the lead.

Even more strangely, the contact eventually ends up being owned by the lead owner, but when before/after insert triggers and workflow rules fire on the Contact, the ownerid is the executing user.

I plan to open a case with support about this as well, but wondered if anyone had encountered anything like this or found a solution/workaround.

1 Answer 1


According to the documentation, unless you specify the owner with the SetOwnerid method, the owner of the newly created objects will be the owner of the Lead. There are a number of idiosyncrasies around Apex based lead conversion, especially regarding the record owner, and the order of execution. But, I have a lot of success in doing the conversion in an after insert/after update trigger and doing my own merging and ownership setting.

  • Regardless of whether or not I use the SetOwnerId method for the LeadConverts, in the before insert context for the resulting CONTACT the OwnerId is the user executing the transaction and not the OwnerId of the corresponding lead. I'm thinking of doing something in the Contact before insert context to query down to the lead object where isConverted == false and creating a map to then set the Contact.OwnerId = Lead.OwnerId before any other logic executes, which might solve my problem. Commented Apr 7, 2015 at 22:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .