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
Laura BrewerLaura Brewer 

Validation Help

I'm trying to write a validation rule to enforce a selection in the "Industry Sub-Type" field once a particular "Industry" selection is made.  But the Validation I've written isn't yielding the proper result.  Can anyone help with my rule?

AND( ISPICKVAL(Industry, "Inland, Offshore"), ISPICKVAL( Industry_Sub_Type__c , "") )
Pankaj_GanwaniPankaj_Ganwani
Is Industry_Sub_Type__c of type multiselect picklist? If so, then use INCLUDES instead.

ISPICKVAL(Industry, "Inland, Offshore") && IF(INCLUDES( Industry_Sub_Type__c , ""),true,false)
goabhigogoabhigo
Hi Laura,
There is similar thread here - https://developer.salesforce.com/forums/ForumsMain?id=906F0000000kBszIAE.

You can achieve this by making the Industry_Sub_Type__c field dependable on Industry field, then make the Industry and Industry_Sub_Type__c field mandatory in the page layout. This will work if the user must select Industry value. If you dont want to enforce that, then follow the below approach:
I am assuming that Inland and Offshore are 2 different values of Industry picklist. If yes, change your validation rule to:
AND(
 OR( ISPICKVAL(Industry, 'Inland'), ISPICKVAL(Industry, 'Offshore') ),
 ISPICKVAL( Industry_Sub_Type__c , '')
)

Let me know what works for you.

--
Regards,
Abhi.
Pankaj_GanwaniPankaj_Ganwani
Hi goabhigo,

By making field dependancy we can only restrict the user from front end to select only permissible values, but from backend still user can populate the random picklist value. So, best solution is to use the validation rule which can restict the user from both front end and backend.

Thanks,
Pankaj