0

I have validation rule on Account Shipping Address.

AND (
ShippingCountry = "United States" || ShippingCountry = "Canada",
isBlank(ShippingState)
)

The standard Lead Mapping feature of Salesforce Maps the lead Address to the Account Billing Address.

When Converting Lead to Account, the validation rule fires. As a result, the lead conversion throws an error 'Shipping State Required'

I don't want to disable the Lead Setting 'Require Validation for Converted Leads' because that would mean all validation rules will be skipped.

After researching, One idea I came across here was Bypassing the Shipping Address Validation error by creating two Custom checkboxes. One on lead, one on Account. However this requires me to now create a flow to undo the check box. Which is fine, however, this errors out the flow that exists on the Account, which basically Autopopulate the Account Name based on the Account Address.State.

Does anyone have other suggestions or ideas to bypass the validation rule for lead conversion to Account ?

1 Answer 1

1

Do the following:

  • Create a checkbox formula field on Lead called Is_Lead__c. Default value = true
  • Create a checkbox field on Account Is_Created_by_Lead_Conversion__c.
  • Add to your lead conversion mapping rules Lead.Is_Lead__c => Account.Is_Created_by_Lead_Conversion__c

Then, change the VR to:

  IF (ISNEW() && Is_Created_By_Lead_Conversion, /* ignore shippingState check on new lead conversion */
      FALSE,  
      AND(    
       ShippingCountry = "United States" || ShippingCountry = "Canada",
       ISBLANK(ShippingState)
      )
   )

Plus, you get the bonus of knowing which Accounts were created by lead conversion. The same technique can be used for Opportunity VRs.

3
  • Thanks @Cropredy. That's the best solution. However, now a flow on the Account object throws error when converting the lead 'flow tried to update records: FIELD_CUSTOM_VALIDATION_EXCEPTION: Please select Shipping State'. Seems like I have to think of all other automation. Mar 31 at 14:58
  • 1
    the flow is probably running after update so ISNEW() is no longer true
    – cropredy
    Mar 31 at 19:42
  • You are right, Flow is running After Update. I came across a solution 'Bypass Validation Rules in Flows' . Not sure if this is the correct approach as this would mean, I would have to do this for all the validation rules now and in future, that would affect Lead Conversion. Apr 3 at 17:22

You must log in to answer this question.

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