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
etechcareersetechcareers 

Collection size 1,287 exceeds maximum size of 1,000.????Help

Hi, i am trying to get a user picklist going of active users. i keep getting the following error:

Collection size 1,287 exceeds maximum size of 1,000.

 

public with sharing class Userform{

    public Userform(ApexPages.StandardController controller) {

    }

  public String val {get;set;}
 
  public List<SelectOption> getName()
  {
    List<User> gd = [Select id, name from User where IsActive=true];     
    List<SelectOption> options = new List<SelectOption>();
    
    for(User f : gd)
    {
       options.add(new SelectOption(f.id,f.Name));
    }
    return options;
   }

}

 

<apex:page standardcontroller="User" extensions="Userform">
<apex:form>
      <apex:SelectList value="{!val}" size="1">         
      <apex:selectOptions value="{!Name}"></apex:selectOptions>
       </apex:SelectList>
</apex:form>        
</apex:page>

 Where am i going wrong....

thanks

 


HariDineshHariDinesh

Hi,

 

I don't think there is wrong in this code. Here your code is reaching Limits that Picklist has.


There are Limits that exist for Number of Characters and number of Entries in a Picklist
Within the 15,000 total character limit, custom picklists can have:
-->Up to 1,000 entries
-->Up to 255 characters per entry

 

so you can not show More than 1000 entries for a single custom Picklist.

 

If needed work around like : create more picklist with user's having different profiles by querying them differently base on Profile

SamuelDeRyckeSamuelDeRycke

Why not use the default user lookup ?  

 

You can use an object with a user lookup as container object in a property, and use an apex:inputfield for the user lookup field.