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
Gaurav Sinha 27Gaurav Sinha 27 

Lightning autcomplete field

Hi all Veterans
I have a lightning account search page, where one of the search criteria is Country(Picklist). I am populating country picklist value from apex class. There is one more field called State. Now the requirement is that the Country picklist value should be set default to the logged in user's country and while we type in state field its should show option to autocomplete the field. Lets say selected country is India, so when we type 'ka' in state field it should show options starting with 'ka ' for rg. Karnataka and so on. Any help will be highly appreciated as its an urgent requirement.

Thanks in Advance
Gaurav Sinha
Ajay K DubediAjay K Dubedi
Hi Gaurav,

You can use Lightning lookup component to achieve your functionality. You can get Country's Name to send it to Apex and can fetch the List of states corresponding to that Country. After this, you just need to set this to the component filed. At the UI part, you just need to replace your existing state field and call the component instead.
Please go through the following link for more details: https://www.jitendrazaa.com/blog/salesforce/lookup-component-in-salesforce-lightning/

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi