+ Start a Discussion

Trigger did not worked properly while Lead convert.



I enable validation and trigger on lead convert in my org.


My code is updating hidden owne field same as account owner,if some is creating new accout or updating account owner field.


Now when user ( like x)convert lead to new account,user pick record owner name(like Y) and convert lead with new account.


Now this new account have account owner name as Y,but while checking hidden owner field value which is X(based on code it should be Y) which is wrong.


Here is my code.


trigger changeRSMDirector on Account (before insert,before update) { Map<String, Account> accountMap = new Map<String,Account>(); for(Account a: System.Trigger.new){ if((a.OwnerId!=null)&& (System.Trigger.isInsert || (a.OwnerId != System.Trigger.oldMap.get(a.Id).OwnerId))){ a.Hidden_Owner__c=a.OwnerId; accountMap.put(a.Hidden_Owner__c,a); } } }

with update account and insert new account without lead convert,Trigger works fine.


Can some one let me know why this trigger is not working while elad convert.




Hi, does anyone know a workaround for this? The following used to work fine until we activated "Enforce Validation and Triggers from Lead":



1.   Lead is created from PRM Portal


2.   Internal user logs into SFDC, changes Lead owner to him/herself, and converts Lead


3.   In my after update Lead trigger, I check if Lead has been converted AND Lead owner is not a Partner (contactid != null). If the criteria are met I add the Partner User to the Sales team.


if l.convertedOpportunityId != null

   if l.owner.contactid != null



Now, after enabling "Enforce Validation and Triggers from Lead", in my trigger convertedOpportunityId is populated as expected, but the Lead owner is still the Partner user, thus my code fails!? Why has enabling this feature caused the new Owner field to not be set when technically conversion has already happened? I don't get it.


Thanks, any help is much appreciated.


Hi muddean17,


I haven't got any solution for this...hope salesforce employee give reply...




A very late response but in case anyone stumbles across it the issue is that LeadConvert pre-dated Apex and the original implementation was never retrofitted to support validation rules or triggers. You should be able to change this yourself now in your org. If you go to Setup > Customize > Leads > Settings you'll see an option labeled "Enforce Validation and Triggers from Lead Convert". If it is disabled, enable it and you should see your validation rules and triggers start firing for all the relevant operations of a lead conversion.


This should be enabled for orgs created within the last year and a half or so.


@mtbclimber, I think this is still an issue. I have the same scenario today.

I have the "Enforce Validation and Triggers from Lead Convert" enabled in the org (NA5).

I have a (before insert, before update)  trigger that copies the Account Owner to the custom "shadow" user lookup field called Account_Manager__c.

Monitoring the debug log, it appears that during conversion, only the Insert fires on the account, and the ownerid that is copied to the shadow field is the lead owner, not the new owner.


Do you have any recommendations on how to address this?