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
ZOEZOE 

Validation Rule Not Working-From Picklist to Text Field

Under my CONTACTS object, I have a picklist that asks "How did you hear about us".  The picklist options are: Internet, Friend/Family, Church, Ad/Print, Event, Other.  I would like a text field to be filled in when any of these choices are chosen so that we know more detail.  What would the validation rule formula be? 

 

I inserted:

AND(NOT(ISPICKVAL( How_Did_You_Find_Out_About_ZOE__c , "Event")),

NOT(ISBLANK( Event_Name__c )))

 

The formula is not working properly!  I tested the formula choosing another option besides EVENT and it wouldn't let me save.

 

Also, is there a way to make the text field ONLY SHOW UP when a certain option is chosen from the picklist?  For example, the the EVENT NAME text field only show up when EVENT is chosen in the picklist?

 

THANKS!

liron169liron169
Hello,

The criteria in the validation said when to raise error.

Currently you write to raise error any time when:
field is not "Event" AND not null
So if you can't save other option then "Event" it's working as you write it.

Please clarify what you're want to achieve with this validation rule?
MellowRenMellowRen

Sorry, I am not sure exactly what you are trying to achieve.

 

Are you trying to put in a validation rule that if someone chooses "Event" in the picklist, they must fill in the "Event Name" field?

 

If so, then this should do it:

 

ISPICKVAL( How_Did_You_Find_Out_About_ZOE__c , "Event") && ISBLANK( Event_Name__c )

  Message: Event name is required.
  Location: Field-->Event_Name__c

 

If not, please give more details (preferably with some examples of what the user can and can't do).

 

As to your second question (…is there a way to make the text field…): Unfortunately, no, if you are simply using the standard Page Layouts but, yes, if you are happy enough to delve into Visualforce and Apex Controllers/Extensions.

 

Regards

MellowRen 

 

 

ZOEZOE

Thank you for your responses.

 

MellowRen-Your validation rule formula worked GREAT but because the text field cannot be hidden (without some coding), I think I want to keep it more general.

 

What I would like is if ANY value is chosen from the picklist menu, a text field titled "Additional information" must be required to be filled out .  I was able to find the formula. 

 

ISPICKVAL( How_Did_You_Find_Out_About_ZOE__c , "True") && ISBLANK(  Additional_Information__c  )

 

But when I tested it (I chose a value from the picklist and left "Additional Information" blank), it let me save without filling out the "Addtional Information" field.  This is a issue!  How do I resolve?  THANKS!

MellowRenMellowRen

ZOE

 

The reason it is letting you do the change is because How_Did_You_Find_Out_About_ZOE__c  does not have a text value of "True" (it is not one of your options).

 

I assume that when you say “if ANY value” you mean that it is not blank, or in the User Interface it is not displaying --None--. If so, then this should be what you are looking for:

 

ISPICKVAL( How_Did_You_Find_Out_About_ZOE__c , "") && ISBLANK(  Additional_Information__c  )

 

Note that is two double quote characters with nothing inbetween them.

 

Regards

MellowRen

ZOEZOE
It is still not working with the formula. I am so sorry. I am so new at
this that it is taking me a while to understand SF terminology as well as
techniques.

The validation rule needs to be so if any value is chosen from the
picklist, that the "additional information" text field will be mandatory to
fill in. If the picklist is left blank, then you can leave the "additional
information" text field blank. I would like it so that the use cannot save
the Contact Name if a picklist value is chosen and a blank "additional
information" text field.

Hope that makes sense.

--
Karen Miyamoto
ZOE USA Office Manager
*Follow us on Facebook,
Twitter and our ZOE
blog
*

PO Box 221510
Santa Clarita, CA 91322
661-255-7963 office
661-254-9305 fax
www.gozoe.org
MellowRenMellowRen

Karen

 

Yeah, it was late when I gave you the last reply. I forgot the “NOT”, try this:

 

 

NOT(ISPICKVAL( How_Did_You_Find_Out_About_ZOE__c , "")) && ISBLANK(  Additional_Information__c  )

 

i.e. If the main field’s value is not blank and the additional field is blank, then throw an error.

 

Regards

MellowRen

ZOEZOE
that's awesome! LOL! thanks so much for all your help. It worked!

--
Karen Miyamoto
ZOE USA Office Manager
*Follow us on Facebook,
Twitter and our ZOE
blog
*

PO Box 221510
Santa Clarita, CA 91322
661-255-7963 office
661-254-9305 fax
www.gozoe.org