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

Conditionally Required picklists when lookup field filled out.

I have set up a custom owner field (lookup) and would like to have our status (picklist) and type (picklist) fields required if it is filled out.  The validation rules I've tried don't seem to work.  Any ideas?

You could try writing an Apex trigger.


If your lookup field is not null then throw an error on the two picklists.   This will put the errors right above the required fields.


if(Object.OwnerField != Null){

       object.StatusField.addError('Put your error message here');

       object.TypeField.addError('Put your error message here')

else{//Do nothing if it is null}


Then you will want to write a test class to make sure the trigger is working properly.  


Message Edited by MSVRad on 08-14-2009 01:32 PM