function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
JP12345JP12345 

How to get changed record owner of lead conversion page?

Requiement:

On lead convert, I want Record owner specified on lead conversion page to be set as Account Executive (This is custom field on Account object).

I have update trigger on lead object which will set Account Owner as Account executive on lead conversion.

On lead conversion, Salesforce assigns system user to Account Owner for a while.After trigger execution ends,it assigns lead owner as an account owner.

 

Question:

How to get changed record owner of lead conversion page in leadtrigger?

 

Any help is appreciated.

crop1645crop1645

In the after update trigger on Lead:

 

1. test to see if the Lead isConverted, if true, then do steps 2-6

2. Fetch the Opportunity from the <lead>,ConvertedOpportunityId field

3. Using the results of #2, you'll have the record owner

4. Fetch the Account using the value in <lead>.ConvertedAccountId field

5. Update the custom field in Account

6. update <theAccount>

 

Be sure to bulkify your after update trigger as it is possible to do batch lead conversions