0

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?

3
  • 1
    are you saying that Require Validation for Converted Leads in Lead Settings is unchecked?
    – cropredy
    Commented Jul 13, 2021 at 23:13
  • Yes that's right. So BeforeTriggers aren't triggering.
    – Amulya
    Commented Jul 14, 2021 at 22:00
  • Are you amenable to using Flow in lieu of Process Builder?
    – cropredy
    Commented Jul 14, 2021 at 22:25

1 Answer 1

1

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.

3
  • 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?
    – Amulya
    Commented Jul 15, 2021 at 21:43
  • 1
    You 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
    – cropredy
    Commented Jul 15, 2021 at 21:52
  • Sure I will find a workaround for that, thank you very much again!!
    – Amulya
    Commented Jul 15, 2021 at 22:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .