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
EvanetEvanet 

Making Fields Conditionally Required - based on picklist

Can someone help me get moving with some data validation please?

I would like to set a field as being conditionally required based on the value of a picklist. By this I don't mean field dependencies - I can manage those easily. What I have is a picklist that shows the specific order type. Based on that selection I would like to have some fields marked as required so that I can enforce some level of process control.



I found this on the validation blog so I am positive this can be done.

  • Make Fields Conditionally Required: Use the familiar and powerful Apex formula language to make fields conditionally required (e.g., based on opportunity stage) or implement record type or role-specific business rules.
The only validation examples I can find are relatively trivial functionality and don't seem to show how to relate fields together.

In a more general sense where would I find references to the language used in these validation rules?

Cheers from Oz

Mal
Harry JamesHarry James

This is a validation rule between two picklists - the Opportunity Stage field and a Loss Category field:

AND ( ISPICKVAL( StageName , "Closed Lost") ,
ISPICKVAL( Loss_Category__c , ""))

This is one between the Opportunty Stage field and a text field - Loss Explanation:

AND ( LEN (Loss_Explanation__c ) = 0,
ISPICKVAL( StageName , "Closed Lost"))

Have you taken a look at this document?

http://na1.salesforce.com/help/doc/en/salesforce_useful_validation_formulas.pdf

EvanetEvanet
Harry - thanks for your help. Your formulas worked fine. I just needed a little help to get my head into the right space.

I had a look through the document your pointed me to and tried to use a similar formula using the ISNULL function which I thought would work in a similar way to LEN = 0 but it did not.

this is what I had.

AND( ISPICKVAL( Service_Tech__c , "ISDN") ,  ISNULL( ISDN_Number_Range__c ) )

Any thoughts why this would not worked? The syntax checked out but it did not fire any error message.

Cheers
Mal


Harry JamesHarry James
What type of field is ISDN_Number_Range__c  ?
 
If it is a text field, the ISNULL function will not work.  Text fields are never null; so ISNULL always returns True. 
 
EvanetEvanet
Yes it is a text field so that explains it. Thanks again.

Cheers