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
Aravind R 11Aravind R 11 

Lightning input text field with dynamic multiple suggestions as soon as user starts typing

Hi All,

I have a requirement where there should be a input text field and as soon as user starts typing, request should go to thirt party api to get address suggestions and should come as drop down under that text box. Once user selects any one of them, it should autopopulate several fields(Like chrome address autofilling).

Since I am new to lightning components, can you please provide me an approach to acheive this? Anticipating your help.


Hi Arvind,

For The Above requirement, you should need to use "Schema Class" Check the below document which salesforce has provided in apex developer guide. VisualForce Page:​
<apex:page controller="schemademo2" >
  <apex:form >
    <apex:pageBlock >
      <apex:pageBlockSection id="fields" >
         <apex:selectList value="{!selectedobject}" label="Object:::" size="1">
          <apex:selectOptions value="{!objname}"/>
            <apex:actionSupport event="onchange" action="{!searchFields}"/>
         <apex:pageBlockSectionItem >
            <apex:selectList value="{!selectedfield}" label="Field:::" size="1">
              <apex:selectOptions value="{!fldname}" />
               <apex:actionSupport event="onchange" action="{!searchValues}"/>
         <apex:pageBlockSectionItem >
            <apex:selectList value="{!selectedvalue}" label="Values:::" size="1" id="values" >
              <apex:selectOptions value="{!valname}" />

public class schemademo2 {   
  public string selectedobject{get;set;}
  public List<selectoption> objname{get;set;}
  public string selectedfield{get;set;}
  public List<selectoption> fldname{get;set;}
  public string selectedvalue{get;set;}
  public List<selectoption> valname{get;set;}
  public boolean pb1{get;set;}
  Map<string,schema.sobjectType> mobj = schema.getGlobalDescribe();
public schemademo2(){
  objname = new List<selectoption>();
  Map<string,schema.sobjectType> mobj = schema.getGlobalDescribe();
  List<string> entities = new List<string>(mobj.keyset());
  objname.add(new selectoption('---Select Object---','----Select Object---'));  
  for(string f:entities){ 
   if (f.contains('__c')) 
  // if (!f.contains('__c'))  
  objname.add(new selectoption(f,f));
public PageReference searchFields() {
  Map<string,sobjectField> mfld = mobj.get(selectedobject).getDescribe().fields.getMap();
  fldname = new List<selectoption>();
  List<string> fldentities = new List<string>(mfld.keyset());
  fldname.add(new selectoption('---Select Field---','----Select Field---'));
  for(string sf:fldentities){
    fldname.add(new selectoption(sf,sf));
    return null;
   public PageReference searchValues() {
     string dquery = 'select '+selectedfield+' from '+selectedobject;         
     List<Sobject> vals = Database.query(dquery);
     valname= new List<selectoption>();
           for(sobject val:vals){
       valname.add(new selectoption(string.valueof(val.get(selectedfield)),string.valueof(val.get(selectedfield))));
       return null;

I hope it will be helpful.​