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
EMasterEMaster 

Trigger on Account that is created from Lead Conversion

When using the standard Lead 'Convert' function, and opting to create an Opportunity on conversion, i am receiving a 'required field' exception from my Opportunity Save Trigger.

 

I know what the error is - one of the custom Lookup fields on the 'Account' object is not getting set during the Lead Conversion process, and the Opportunity that is being created during such process needs that field. Therefore, i need to ensure that dureing the lead conversion process, this custom field is updated to the relevant value (it is a lookup to Contacts)

 

  • Am i correct in assuming a 'Before Insert' trigger needs to be added to the Account object, and if so, is there any way to make this trigger only execute if the Account is being inserted from a Lead Conversion?
    OR
  • Does a trigger need to be added on the Lead object, so it is executed on conversion?

 

Bhawani SharmaBhawani Sharma
Whaeatver value is required on account level, you can map this with Lead's field using Lead account mapping.
EMasterEMaster

I need to map the Lead (i.e the person) to a custom lookup Field on the Account called 'Primary Contact'

 

The Lead Mapping feature doesnt seem to allow me to do this - it seems like its only available for custom Lead fields

Bhawani SharmaBhawani Sharma
In that case you can go with a before insert trigger on account.

Regards,
Bhavi Sharma
Certified Salesforce Consultant
bhavi@simplyforce.com/bhawani.sh.sharma@gmail.com
+91-9928130589
LinkedIn |
Twitter
| Blog |
Community
www.simplyforce.com
EMasterEMaster
Thanks for the reply. So if i sue that approach, is there any way to make this trigger only execute if the Account is being inserted from a Lead Conversion?
Bhawani SharmaBhawani Sharma
You can check any of your mapping value in Account trigger. If that is
populated then record is being created from Lead convert. or you can create
a separate flag on lead and account. and map it. In yout account trigger,
check if that field has value, do you logic.

Regards,
Bhavi S

harma
Certified Salesforce Consultant
bhavi@simplyforce.com/bhawani.sh.sharma@gmail.com
+91-9928130589
LinkedIn |
Twitter
| Blog |
Community
www.simplyforce.com