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
Emma CherringtonEmma Cherrington 

How do I restrict picklist value selection if checkbox = true?

Hi All,

I would like to create a validation rule that prevents a user from choosing particular values from a picklist, based on a checkbox value.  Both fields are on the Account object.

So, the picklist values are:

New ICP
BDR Working
Cold
Revisit

If the checkbox field 'Allocated Account?' = True, I only want the user to be able to proceed if they choose either New ICP, BDR Working, or Revisit. E.g. 'Cold' is not an option if the Allocated Account box is ticked.

To complicate matters, I also want to restrict the picklist choices if 'Allocated Account?' = False, so in that scenario, there would be an error if they tried to select 'Revisit'.  Would I need 2 validation rules, or can this all be accomplished with one?

Hope that all makes sense? Thanks so much in advance for your help!  (Yes, I know I need the API field names, I'm being lazy....will add them in when I actually build it! :-) )

Emma
Best Answer chosen by Emma Cherrington
Ajay K DubediAjay K Dubedi
Hi Emma, you can try below two validation rules:

1. If the checkbox is unchecked or FALSE:
AND( Allocated_Account__c = FALSE, NOT(ISPICKVAL( Account_Picklist__c , "Cold")))
2. If the checkbox is TRUE:
AND(Allocated_Account__c = TRUE, ISPICKVAL( Account_Picklist__c , "Cold"))
Hope it helps!

Thank you,
Ajay Dubedi

All Answers

Emma CherringtonEmma Cherrington
Just to add......I know that I could accomplish this by having a separate record type for Allocated vs Non Allocated, and assigning different picklist values to each record type, but I really would rather avoid doing that for reasons that I won't go into here as it isn't relevant......I'm happy for the non selectable values to appear to the end user, as long as they get an error message when they try to select them / on saving the record if they have selected them.  Thanks!  :-)
Ajay K DubediAjay K Dubedi
Hi Emma, you can try below two validation rules:

1. If the checkbox is unchecked or FALSE:
AND( Allocated_Account__c = FALSE, NOT(ISPICKVAL( Account_Picklist__c , "Cold")))
2. If the checkbox is TRUE:
AND(Allocated_Account__c = TRUE, ISPICKVAL( Account_Picklist__c , "Cold"))
Hope it helps!

Thank you,
Ajay Dubedi
This was selected as the best answer
Raj VakatiRaj Vakati
try this
 
IF ( RecordType.Name="Allocated",

AND( Allocated_Account__c = FALSE, NOT(ISPICKVAL( Account_Picklist__c , "Cold"))) , FALSE )

 
Emma CherringtonEmma Cherrington
Thanks!  Not quite what I needed, but gave me enough info to work out what I did need!  :-)