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
API User 189API User 189 

How to populate Opportunity fields of the opp that is created during Lead conversion

When a Lead is converted into an account, it gives the option to create a Pipeline opportunity. My issue is that if selected, I cannot edit this opportunity's fields via a trigger (I have both a trigger for when the Opportunity is created and when a Lead is converted and neither work for that opportunity). Strange thing is that if the opportunity is created before or after the conversion, my triggers are able to edit these fields. Is there a reason that the conversion opportunity is uneditable? Is there a workaround to this problem?
Naval Sharma4Naval Sharma4
Make sure you have enabled Require Validation for Converted Leads setting.
User-added image
This can be located under App Setup > Customize > Leads > Lead Settings.

 
API User 189API User 189
@Naval Sharma4 I enabled it, but it didn't work. The resulting pipeline opportunity was created with all the specified fields left blank.
Naval Sharma4Naval Sharma4
Did you try to debug it? Are you getting any debug logs for that opportunity trigger?
 
Naval Sharma4Naval Sharma4
To check if a Lead has been converted and do custom lead conversion logic, the best home for such is the LeadAfter trigger, where you can check.
 
If (trigger.isUpdate && Lead.IsConverted && !trigger.oldmap.get(lead.id).IsConverted)
//do your stuff

You might want to have a look at the following stackoverflow question - 
http://​​​​​​​https://salesforce.stackexchange.com/questions/3956/lead-conversion-trigger-order-of-execution (http://https://salesforce.stackexchange.com/questions/3956/lead-conversion-trigger-order-of-execution)