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
Stefaan Somers 11Stefaan Somers 11 

Validation rule on list of values

Hi,

we have a picklist of 100 values. Now we need the following requirement.
- there is a check-box field
- if field is checked only a limit amount of those 100 picklist values should be allowed
- it should be possible to configure these limited picklist values, without hardcoding this somewhere

In custom settings or custom meta-data you can only define 1 value 
Raj VakatiRaj Vakati
You can move it into the custom metadata and refer the values from the custom metadata in valudation rules 
https://help.salesforce.com/articleView?id=custommetadatatypes_validation_rules.htm&type=5
Ajay K DubediAjay K Dubedi
Hi vijay,

please try below code:

Vf Page :
 
<apex:page controller="objectLists" >
  <apex:form >
    <apex:SelectList value="{!val}" size="1">
      <apex:selectOptions value="{!Name}"></apex:selectOptions>
    </apex:SelectList>
  </apex:form>
</apex:page>

Controller :
 
public class objectLists{
  public String val {get;set;}
  public List<SelectOption> getName()
  {
  List<Schema.SObjectType> gd = Schema.getGlobalDescribe().Values();   
 List<SelectOption> options = new List<SelectOption>();
    for(Schema.SObjectType f : gd)
    {
      options.add(new SelectOption(f.getDescribe().getLabel(),f.getDescribe().getLabel()));
    }
    return options;
   }
}
Please mark as best answer if it helps you.

Thank You
Ajay Dubedi