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
JRBAccruitJRBAccruit 

Require Multiple Fields based on Picklist Value Selected

All,

I'm probably just not thinking clearly, but how can I require the completion of several fields based on the selection of a certain value in a picklist field?

I could do a series of Valudation rules (one for each field I need completed), but that sounds a bit inefficient . . .

Thanks!
Best Answer chosen by Admin (Salesforce Developers) 
NPMNPM
AND(
ISPICKVAL(Picklistfield,"a"),OR(ISNULL(field1),ISNULL(field2),ISNULL(field3))
)

All Answers

NPMNPM
You should be able to do this with one rule that evaluates to TRUE.
 
AND(
Picklistfield="a",OR(field1 <>"",field2<>"",field3<>"")
)
 
This would trigger the rule when the picklist is a certain value (a) AND any or all of fields 1, 2, or 3 are null.
 
Depending on the field types you may need to use other functions/operators to check for null or not.
NPMNPM

for example knowing the one field is a picklist:

AND(
Picklistfield="a",OR(field1 <>"",field2<>"",field3<>"")
)
 
Would change to
 
AND(
ISPICKVAL(Picklistfield,"a"),OR(field1 <>"",field2<>"",field3<>"")
)
JRBAccruitJRBAccruit
Thanks a lot!  I'll give it a try.
JRBAccruitJRBAccruit
Strange, I'm getting an error that says "Incorrect parameter for function <>"". Expected Number, received Text"

Any thoughts?
NPMNPM

Yes - that was why the comment about using the different methods for null.  The method I gave works only for text.

You probably need to use ISNULL(field1) for example

 

NPMNPM
AND(
ISPICKVAL(Picklistfield,"a"),OR(ISNULL(field1),ISNULL(field2),ISNULL(field3))
)
This was selected as the best answer
JRBAccruitJRBAccruit
Works great.  Thanks!
cjpdevcjpdev
How did you get this to work?  I'm trying to do this for the Billing Address fields based upon a value in the Account type field.  The syntax check comes back fine but the rule doesn't work.  What am I missing?
 
AND(
ISPICKVAL(  Type  ,"Customer"),OR(ISNULL( BillingStreet),ISNULL( BillingCity),ISNULL( BillingState ),ISNULL( BillingPostalCode ),ISNULL( Billing_Attn_Line__c ))
)
NPMNPM
Check your field types.  For example ISNULL does not work with Text fields.  You may need to substitute using the LEN() functions or <>""