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
sam sjsam sj 

Unable to restrict number of values for custom autocomplete feature built for a field in visualforce page

Hi, 
  I have a visualforce page where in a particular field I am using salesforce list attribute to display the fetched records from database via autocomplete. As per the autocomplete feature it's showing all the related records as per the user's search. Is there a way to limit number of records seen in autocomplete as it looks odd to display all records. I want to restrict it to show 10 names in autocomplete. Code im using is
              <apex:input label="office" value="{! selectedAccount }" list="{! Accounts}"  id="txt"  /> 
In apex controller im using a getter to fetch records through query and its been used by list attribute .
 
bob_buzzardbob_buzzard
You should be able to add a 'limit 10' clause to the SOQL query to achieve this, assuming you don't want to send all records across and only display 10 of them.
sam sjsam sj
HI bob, what I m actually doing is getting all list of records of an object using soql when constructor is loaded and using autocomplete feature where control is back and forth between visualforce page and controller. I m not querying at the backend for each letter the user types in the field