I hope this is easy, but I'm just having a brain fart. I need to make one of the status values in a picklist field status to be disabled unless a different field on same object = false.
2 Answers
You can use a simple validation rule, if your preference is to surface an error. (You've tagged your question validation-rule
). Something like
ISPICKVAL(My_picklist__c, 'RESTRICTED_VALUE') && NOT(Other_field__c)
This assumes that Other_field__c
is a checkbox field.
Note, however, that this doesn't disable the entry in the picklist user interface: it simply prevents a record from being saved with this combination of data points.
Alternately, you can make a checkbox field the controlling field of your picklist. This would allow you to determine which picklist choices show up at all based on the checkbox's selection state.
-
Yes this looks awesome thank you, I only want the one picklist value to be restricted on save IF the other (checkbox) field is false Commented Apr 4, 2018 at 16:01
-
New question. How would I make the vice-versa of this? I have the value I want restricted if the other field referenced is false. Now for the other field in the picklist I want restricted if the other field referenced is true. Basically how do you have multiple fields into that ISPICKVAL expression? Do I need to make multiple validation rules or can this be done inside of one? Commented Apr 5, 2018 at 21:58
-
Either way. You may want a second validation rule to surface a different error message, or you can wrap multiple expressions like this in the OR() function. Commented Apr 6, 2018 at 0:08
-
Thanks so much for your help. I wound up doing 5 ISPICKVAL’s inside () and the NOT(other_field__c = true), what I needed was one VR for when the other_field__c was true and one for when it was false. Thanks again! Commented Apr 6, 2018 at 0:58
-
Sure thing. If you develop a lot of complexity here you may want to revisit picklist dependency and see if it meets your needs for this solution. Commented Apr 6, 2018 at 1:16
You have to setup Field Dependency:
- From the management settings for the object you want to add a field to, go to Fields. Custom task and event fields are accessible from the object management settings for Activities.
- Click Field Dependencies.
- Click New.
Choose a controlling field and dependent field.
- Note Some picklist and checkbox fields may not be available as controlling fields.
Click Continue.
- Use the field dependency matrix to specify the dependent picklist values that are available when a user selects each controlling field value.
- Optionally, click Preview to test your selections. If your organization uses record types, choose a record type to test how it affects your controlling and dependent picklist values. The record type controls what values are available in the controlling field. The record type and the controlling field together determine what values are available in the dependent picklist. For example, a dependent value is only available if it is available in the selected record type and the selected controlling value.
- Click Save.
- Note The Filter by Record Type option doesn’t appear in the Preview window for activity custom fields.
-
2Please don't write a link-only answer. Links can go bad, and the information lost. See How to Answer for guidelines on writing a good answer.– sfdcfox ♦Commented Apr 4, 2018 at 16:12