Skip to main content

Autocomplete Lookups for Salesforce1

We all are seeing that Salesforce1 is evolving with every passing day and there is yet lot to be done. One of the many items is a custom lookup field on a Visualforce page.

Lightning design systems do provide us with the CSS we can use to create lookup fields the logic has to be written by the developer. Below is a basic example that can be used to implement the basic autocomplete version of the lookup field.

The auto complete text box is implemented using the CSS provided by Salesforce1 lightning design.

The Visualforce page uses Visualforce remoting to fetch records based on the user input. A call to the controller method is made every time a keyup event is fired and the results are updated.


  1. Great post, thanks! Could you please tell me how to access the contact ID of the selected element? j$('#lookup').val() returns the name of the selected contact but i would like to know the ID. Thanks again.

  2. Thanks Dev. Id is saved as one of the attributes hence you can retrieve using that attribute value.
    var id = $('#lookup').attr('aria-activedescendant');

    1. '<a id="' + in your code doens´t work, so record id is not saved on the <a> element. Also changing your debug "console.log(this);" in "console.log(;" i see that is not the record id but undefined I tested in google Chrome.Any solution? Thank you.

    2. Here is the fixed and working code which alerts the Contact name and Id when you select a contact name:

  3. Gulshan, thanks a lot for that awesome post!
    (although it will be cool to remove the search words div if the input is blank, and also not doing a search on less than 2 letters.. But really great post so 10Q!!)

  4. can you please provide jquery_all static resource

  5. This comment has been removed by the author.

  6. The Venetian Hotel Las Vegas - JSHub
    The Venetian Las 남양주 출장안마 Vegas hotel 제천 출장안마 features an outdoor 전라남도 출장안마 pool and 대구광역 출장샵 spa, plus an indoor pool. Guests will be able to 청주 출장안마 enjoy various amenities such as complimentary WiFi


Post a Comment

Popular posts from this blog

DumpIT - Migrate / Clone Salesforce Org - Data

How complicated can it be to clone data from one Salesforce Org to another? It can take from minutes to weeks depending on the number of objects and relationships between them. I am glad to share a tool I developed which may save you a lot of time. DumpIT comes as an executable jar file which helps to clone data from one Salesforce Org to another. Recently Salesforce released a feature to clone a Sandbox but it has its own limitations and cannot always be used. How to use DumpIT? Prerequisite - You must have Java installed and setup on your local machine. Try running "Java -v" command on your command prompt to make sure its all setup and working.  Step 1: Download the tool Download the tool from this link Create a folder on your local machine and place all the three downloaded items in that folder. You will see these three items: results folder: Success and Error files are placed on this folder on execution, for each object. You can

Exporting Files/Attachments from Salesforce

While working on a Salesforce migration project where I was asked to export a set of attachments from one Salesforce Org to another, I developed this tool. The customer had millions of attachments in their source Org and only a few thousands had to be migrated. What are the existing options in the market? Few of the existing options suggested by different people were: Use Weekly Export. I could use it but I only had to export a few thousand attachments from millions and I can only run it once a week. Use The free version only allows me to extract limited records on a day. Where can I download this from? I developed a JAR file which did the job for me and wanted to share it with everyone.  Download URL: There are 2 files SFDCFiles.jar First step is to setup with the Org credentials and SOQL to extract data from. How to run this? To run this Jar file execute the below command on yo