0

I have been trying to get Account values auto populated in a input field called Account like there is a text box and I try to enter app then if Apple exists as a account then that value pops up and I select that account and that value sets up in the text box. Can some one guide me how to achieve this stuck on this from long time.

Tried Jitendra Jaa ACCOUNTJSON creator but did not work.

  • There is a Jquery plugin - "Autopopulate" and you need to leverage this plugin in your visualforce page. I will share the details with you in some time. – the_phantom Jun 11 '15 at 4:51
0

Try this .I have pasted both page code and class code there.Paste those code in proper place it will work fine.

<link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css"></link>

.ui-autocomplete-loading { background:url('/img/loading32.gif') right center no-repeat !important; background-size:15px 15px !important; margin-right:5px; }

$(document).ready(function(){ var allAcc; $("[id$='txtCompanyName']").autocomplete( { minLength: 3, source: function(request, response){ queryTerm = request.term; UserController.initializeAcc(request.term, function(result, event) { if(event.type == 'exception') { alert(event.message); } else { allAcc = result; response(allAcc); } }); }, focus: function( event, ui ){ $("[id$='txtCompanyName']").val( ui.item.Name ); return false; }, select: function( event, ui ) { $("[id$='txtCompanyName']").val( ui.item.Name ); return false; } }) .autocomplete( "instance" )._renderItem = function( ul, item ) { return $( "
  • " ) .append( "" + item.Name +"
    " + item.BillingCity+','+item.BillingStreet+','+item.BillingState+','+item.BillingPostalCode+','+item.BillingCountry + "" ) .appendTo( ul ); }; });

    ========================Class Code============================== @RemoteAction public static list initializeAcc(String searchString) { list accList = new list(); String accName = searchString.trim();

        if(accName !='')
        {
            String queryString = 'select Id,Name, BillingCity,BillingStreet,BillingState,BillingPostalCode,BillingCountry from Account where Name like \'' +accName+ '%\'';
            try
            {
                accList = Database.query(queryString);
            }
            catch(QueryException e)
            {
                System.debug('======Exception getting specif Account'+e);
            }
        }
        return accList;
    }
    

    Your Answer

    By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

    Not the answer you're looking for? Browse other questions tagged or ask your own question.