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
ankushankush 

Want to pre-populate or auto populate all Account Names in database based on typing

We have a scenario where a user needs to enter a form with some details like name email company. When he tries to enter company name that field should basically point to the Account names in salesforce database and like when he tries to enter say like goog the page needs to recognize the accounts with the names goog in database and may be populate something like google. when he tries entering ama it should populate like amazon (those accounts exists in datbase but trying to prepopulate.) Can some one guide me on this please how to accomlish this task.
pconpcon
To do this, it will require a non-trivial amount of Javascript and Apex work.  When I have done this in the past, I have a Visualforce page that has an @remoteAction [1] on it that is called by the Javascript on change of the field.  This remote action then queries an Accounts that start with (or contain) the string being typed.  The remote action then returns back that list of accounts and the Javascript then does a call to a library for type ahead [2][3].  Then once an Account is selected from the typeahead, it is stored on a hidden field that is bound to the controller.  The controller then uses the hidden field to set the accountId on the record when saving.  This can be very slow depending on the number of accounts you have.

[1] http://www.salesforce.com/docs/developer/pages/Content/pages_js_remoting.htm
[2] https://twitter.github.io/typeahead.js/
[3] http://jqueryui.com/autocomplete/
Pankaj_GanwaniPankaj_Ganwani
Hi Ankush,

This link can help you out:
http://anupjadhav.com/2013/02/01/jquery-autocomplete/