+ Start a Discussion
Pavushetti Abhilash 3Pavushetti Abhilash 3 

Show custom object field values in LWC combobox dropdown

Hi everyone.
I have a custom object Address__c. In address there are few fields called Strret, Colony, City, State, Country. In LWC combobox drop down, these custom object fields should display. Please let me know the required code part. For example just like in Amazon while selecting delivery we will get picklist values with addresses linked to account. If we have 4 addresses amazon will ask in dropdown the ask to select one address. 
Hii Pavushetti 
Try Below Code
            name="List Of Fields" 
            label="List Of Fields"
            placeholder="List Of Fields" 

import getfields from "@salesforce/apex/FieldList.getfields";

 @track data = [];
    get Options() {
        return this.data;

      @wire(getfields, {
        objectname: 'Account'
        this.wiredActivities = value;
        const { data, error } = value;
        if (data) { 
            let datas = JSON.parse(JSON.stringify(data));
        let lstOption = [];
      for (var i = 0;i < datas.length;i++) {
          lstOption.push({value: datas[i].QualifiedApiName,label: datas[i].DeveloperName
        this.data = lstOption;
           } else if (error) {  
    handleChange(event) {

public with sharing class FieldList {
    public static List<FieldDefinition> getfields(string objectname){
        string query = 'select DeveloperName,QualifiedApiName from FieldDefinition where EntityDefinition.QualifiedApiName = :objectname ORDER BY DeveloperName ASC';
        list<FieldDefinition> lstObject = Database.query(query);
        system.debug('lstObject==> '+lstObject);
        for(Integer i=0;i<lstObject.Size();i++){
            system.debug('lstObject==> '+lstObject[i].QualifiedApiName);
        return lstObject;
Please Mark It As best Answer If It Helps
Thank You!
Pavushetti Abhilash 3Pavushetti Abhilash 3
Hi CharuDutt. Thanks for your reply, I didnt get any error in above code. Unfortunately its not working. Because the object related to one customer account id. But it throws response in Map. So modified code as below.

                                name="Collection Address"
@track Options =[];
    setofAddress= [];
    @wire(getCollectionAddress, {userid: USER_ID})
    wiredclass({data, error}){
            const addressVal = data;
            let setOptions = Object.values(addressVal);
            for(let i = 0; i<setOptions.length; i++){
            this.Options = this.genSiteAddress(this.setofAddress);
        return data.map(item=>({label:item, value:item}))
    handleChange(event) {
------------------------------APEX CLASS-----------
    public static List<r4c_Collection_Address__c> getCollectionAddress(String userid){
        Id LoggedInUserID = userid;
        User getcustomerUserId = [Select ID,AccountId From User WHERE ID=: LoggedInUserID];
        ID customerAccount = getcustomerUserId.AccountId;
        List<r4c_Collection_Address__c> collectionAddress = new List<r4c_Collection_Address__c>();
        collectionAddress =  [SELECT ID,r4c_Street1__c,r4c_Street2__c,r4c_City__c,r4c_Zip_Postal_Code__c,
                            r4c_State_Province__c,Country__c FROM r4c_Collection_Address__c WHERE Account_Name__r.Id =: customerAccount];
return collectionAddress;