+ Start a Discussion
cpierrecpierre 

VALIDATION RULE HELP -Can I make a look-up field required based on a picklist value?

How do I write the the validation rule that makes a look-up field required based on the value of a picklist?
There are two values in the pick list this would need to check on.
 
So,  if picklist value = ABC or XYZ  make Look-up field required.
 
Writing formula's is not my strong point so any help here would be greatly appreciated
 
:smileywink:
Thanks in advance
 
Chris_627Chris_627
"So,  if picklist value = ABC or XYZ  make Look-up field required."  

Your formula syntax would be:

AND(
  OR(
  ISPICKVAL( <insert your picklist> , "ABC"),
  ISPICKVAL( <insert your picklist>, "XYZ")
  ),
<insert the merge field for your lookup.id> = "")

The example below makes the Account field on a Case required based on the Case Origin field:

AND(
  OR(
  ISPICKVAL( Origin , "Phone"),
  ISPICKVAL( Origin , "Web")
  ),
Account.Id = "")

Hope this helps. Also, check the Salesforce Help & Training and search "Useful Validation Rules". There are a lot of examples that usually don't need too much modification to be adapted to whatever fields you want to validate.
Chris_627Chris_627
sorry about the smilies - I didn't expect that... those should all be right parentheses
cpierrecpierre

Thanks so much for the help - I got it to work - but made one tweek.

Rather equal to null -  I used  Not equal to null

<insert the merge field for your lookup.id> <> ""

:smileyhappy:

 

Chris_627Chris_627
Validation formulas are true/false expressions and when they return "true" it prevents the record from saving --- If you changed the "equals null" to "not equals null" you are basically telling salesforce "Do not save the record if this lookup field is not null". You should be getting a valiation error whenever the picklist values referenced in the OR statement are selected AND the lookup has a value in it.