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
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. 
CharuDuttCharuDutt
Hii Pavushetti 
Try Below Code
LWC
  <lightning-combobox 
            class="slds-m-around_small" 
            name="List Of Fields" 
            label="List Of Fields"
            placeholder="List Of Fields" 
            value={value} 
            onchange={handleChange} 
            options={Options}>
        </lightning-combobox>

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


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

      @wire(getfields, {
        objectname: 'Account'
    })
    wiredclass(value){
        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) {  
            console.log(error);
           }  
    }
    handleChange(event) {
        alert(event.detail.value);
    }


Apex
public with sharing class FieldList {
   
     @AuraEnabled(cacheable=true)
    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.

<lightning-combobox 
                                name="Collection Address"
                                value={value}
                                options={Options}
                                onchange={handleChange}></lightning-combobox>
----------------------------------------JS--------------------------------------
@track Options =[];
    setofAddress= [];
    @wire(getCollectionAddress, {userid: USER_ID})
    wiredclass({data, error}){
        if(data){
            console.log(data);
            const addressVal = data;
            let setOptions = Object.values(addressVal);
            for(let i = 0; i<setOptions.length; i++){
                //console.log(setOptions[i].r4c_Street1__c+','+setOptions[i].r4c_Street2__c+','+setOptions[i].r4c_City__c)
                this.setofAddress.push(setOptions[i].r4c_Street1__c+','+setOptions[i].r4c_Street2__c+','+setOptions[i].r4c_State_Province__c+','+setOptions[i].r4c_City__c+','+setOptions[i].Country__c+','+setOptions[i].r4c_Zip_Postal_Code__c);
            }
            console.log(this.setofAddress);
            this.Options = this.genSiteAddress(this.setofAddress);
        }
        if(error){
            console.log(error);
        }
genSiteAddress(data){
        //console.log(data)
        return data.map(item=>({label:item, value:item}))
    }
    handleChange(event) {
        alert(event.detail.value);
    }
------------------------------APEX CLASS-----------
@AuraEnabled(cacheable=true)
    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;
}