I have a Validation Rule in which there are 2 picklist fields and one text field. I am writing VR for text field.
The 1st picklist_field1__c which have values like (text -abc, text-def, text-xyz, help, chat, email) and another picklist_field2__c has value "phone" and other one is a simple text_field__c .
I created a VR on text_field__c so that when the picklist_field1__c value is text -abc, text-def, text-xyz, help, chat then only user can enter values manually in text_field__c. If the picklist value is anything else like email the user should get an error entering anything in the text field. This is the VR I wrote but it is having 2 issues.
- I need to add null check so that if picklist field1 and picklist field2 are null nobody should be able to edit text field. They should get an error in that case too on text field.
- while testing I was changing the picklist value from email to help and text field was set to null and while changing it to value "help" the VR was firing too. It seems like the VR is preventing the wrong field from being edited. For some reason I was able to edit picklist from email to text but i am only getting error when changing the value from email to help.Whenever I am changing the value to help the VR is firing.
How do I fix these 2 issues?
OR(
AND(
OR(
CONTAINS(TEXT(picklist_field1__c), 'text-'),
ISPICKVAL(picklist_field1__c, 'help'),
ISPICKVAL(picklist_field1__c, 'chat'),
ISPICKVAL(picklist_field2__c, 'phone'),
),
ISBLANK(text_field__c)
),
AND(
ISPICKVAL(picklist_field__c, 'email'),
NOT(ISBLANK(text_field__c))
)
)