1

I am working on a validation rule where I have 2 fields, one picklist and one text field.

I want to throw an error to the text field when someone tries to manually enter abc, def, xyz.

So far I have this

IF(
    ISPICKVAL(picklist_field__c , 'abc, def,xyz'),
    text_field__C, 
    null 
)
4
  • 1
    Validation rules cannot update fields, they only prevent records from being saved when the given condiitons/formula evaluates to true. To update a field, you'd want to use a before-save flow (workflow rules and process builder are starting to become deprecated).
    – Derek F
    Commented Mar 8, 2022 at 23:10
  • Basically, it just means, if anyone tries to enter something on that field, and it doesn't match the VR criteria, block it from saving.
    – user107526
    Commented Mar 8, 2022 at 23:23
  • Sorry my bad I dont want to update the field we just want to block the field if someone tries to update the text field to abc, def, and xyz.
    – user107526
    Commented Mar 8, 2022 at 23:29
  • Unfortunately VR doesn't support reflection (to be able to read available picklist values) so you could make formula dynamic. Instead, you should edit VR to include all valid values like mentioned by @cropredy
    – metasync
    Commented Mar 9, 2022 at 0:44

1 Answer 1

0

You would do the following

OR(Text_Field__c='abc',
   Text_Field__c='def',
   Text_Field__c='xyz') 
       

or, something that looks cleaner and compiles in fewer bytes

'1' = CASE(Text_Field__c,
           'abc','1',
           'def','1',
           'xyz','1',
           '0') 
8
  • With this formula how should I use picklist field cos abc,def,xyz are picklist values.
    – user107526
    Commented Mar 9, 2022 at 5:54
  • Maybe I misunderstood your question. Edit your post with a concrete example
    – cropredy
    Commented Mar 9, 2022 at 5:56
  • Sorry for the confusion. i just edited the question.
    – user107526
    Commented Mar 9, 2022 at 6:40
  • If you edited the original question, I'm still in the dark as to the requirement. Are you trying to validate the text field's entry or the picklist entry? If the latter, are you trying to put the error into the text field? If the latter, VR can't do this
    – cropredy
    Commented Mar 9, 2022 at 18:17
  • I am validating the text field's entry and show error on the text fiel.
    – user107526
    Commented Mar 9, 2022 at 19:08

You must log in to answer this question.

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