+ Start a Discussion

Find out Account's/Contact's new Owner in a Trigger after Lead Conversion



Is it possible to get to know the new Owner of the new created Objects Account/Contact in a trigger while a lead is being converted?


In the After/Before Insert Trigger of Account/Contact the OwnerID is set to the Owner of the Lead.

In After/Before Update Trigger of Lead, if I try to query Accounts/Contacts OwnerID (Using [SELECT OwnerID from Account where ID=:ConvertedAccountID]), I still get the ID of the user that owns the Lead, not the new User.

The After/Before Update Trigger of Account/Contact is NOT executed.


Any Ideas/Help?


Have you tried this?




(ie Id oldOwnerId = trigger.old[0].OwnerId;)


thank you JeffStevens, 

In lead conversion the Lead itself doesn't change the Owner - only the new created Account/Contact are assigned to the new owner. I'm looking for the new owner, not the old one.

Anup JadhavAnup Jadhav

Hi there,


Lead conversion is a special process, and according to the Salesforce docs.


If you have a trigger set to fire when new records are created, the trigger temporarily assigns a system user as the owner of the created records. After the trigger finishes, the owner is set to the lead owner.

 I think this happens even whe you explicitly specify a new owner during the convert process.


More juicy details here: http://eu1.salesforce.com/help/doc/en/leads_convert.htm







I tried it, and in my case the Owner of Account/Contact in the After/Before Insert trigger was the current User (owner of the Lead - the system administrator). NO After/Before Update trigger is called :(


So salesforce changes the owner without calling Triggers (even though the Setting "Enforce Validation and Triggers from Lead Convert" is enabled)


How can I find out the new Owner? I can't imagine it's not possible ....

Anup JadhavAnup Jadhav

why do you think Update trigger should be called? Isn't this an insert process?


- Anup


OwnerID is being updated AFTER the Insert operation.The Account is inserted with another OwnerID. In the Salesforce database the Account is stored with the new OwnerID


For a developer to be able to react to this change, an update trigger should be called ...


Anup JadhavAnup Jadhav

According to this only Apex before triggers are fired.









thank you. Unfortunately my apex before Update trigger doesn't fire at all. Perhaps it fires if there are any workflows assigned.


The question remains: how can I access the new (destination) ownerid of Account/Contact in a trigger ?


okay - what about puttting the trigger on the Account, in an after update?


Then you can check for any matching Leads, (ConvertedAccountId) and the IsConverted field.


ImpactMG wrote:The After/Before Update Trigger of Account/Contact is NOT executed.


The Order of Execution is:

* OnBeforeInsert of Account (Lead was not changed yet)

* OnAfterInsert of Account (Lead was not changed yet)

* OnBeforeInsert/OnAfterInsert of Contact and Opportunity (Lead was not changed yet)

* OnBeforeUpdate of Lead (Select OwnerID from account where id=:Lead.ConvertedAccountID returns the OLD OwnerID)

Warren WiseWarren Wise
ImpactMG, were you able to resolve this situation?
Warren Wise,
unfortunately not.
This does not work for new Accounts/Contacts. It does work for existing Accounts/Contacts, though (in case the lead is converted to an existing Account/Contact).