I need to populate Contact Country field with Account's Country value when Lead is converted to Contact and Country field on Lead record is blank. We cannot do it on Before Insert trigger since that setting(Require Validation for Converted Leads) on Lead is turned off. Neither on After Insert Apex Trigger nor using Process Builder. Tried both already. So what would be the best way to achieve this?
1 Answer
Given that Require Validation for Converted Lead
is unchecked, DML events on the converted objects (Account, Contact, Opportunity) do not initiate triggers or other automation.
However, there will be a DML event on the Lead itself (to set IsConverted = true
and also set the Ids of the converted Account, Contact, and Opportunity.
So, using either an after update trigger or after save Flow on Leads where IsConverted=true
, you can query for the converted Account and Contact and set the Contact's Country per the converted Account.
-
Thank you!! I used After Trigger on Lead object and it almost worked. Only issue is, if there is any Contact validation error, it's stopping Trigger execution. Though we have disabled the setting, it's still throwing validation error!! Any advise?– AmulyaCommented Jul 15, 2021 at 21:43
-
1You would need to amend the Contact VR to allow your update to occur; VRs run at the database level and are designed to prevent invalid data from being saved. You can not bypass VRs; you can only change the VR's conditions– cropredyCommented Jul 15, 2021 at 21:52
-
Sure I will find a workaround for that, thank you very much again!!– AmulyaCommented Jul 15, 2021 at 22:06
Require Validation for Converted Leads
in Lead Settings is unchecked?