You need to sign in to do that
Don't have an account?
Display Apex controller result in Dropdown list in LWC
Hello LWC experts,
I'm facing issue display the Apex controller result in LWC. so i want to display in the form of dropdown list in my LWC. can someone please help with this and Thank you in Advacnce
Apex:
@AuraEnabled(cacheable=true)
public static List<InsurancePolicyParticipant> showOnlyBDIpolicy(string AccountId){
return [SELECT Id, InsurancePolicy.Name FROM InsurancePolicyParticipant
WHERE PrimaryParticipantAccountId =: clientId];
}
JS file:
get productNumberOptions(){
console.log('*** '+JSON.stringify(this.productOptions))
return this.productOptions;
}
handleProductChange(event){
this.productNumber = event.detail.value;
}
@wire(displayBDIpolicy, {AccountId: '$recordId'} )
wiredBDIpolicy({error, data}){
if(data){
console.log('$$$$ '+JSON.stringify(data))
for(let i = 0; i < data.length; i++){
this.productOptions.push({ label: data[i].InsurancePolicy.Name, value: data[i].Id });
}
console.log(JSON.stringify(this.productOptions));
}
if(error){
console.log(error);
showToast(this, 'error', error);
}
}
HTML file:
<lightning-layout-item size="4" padding="around-small" >
<lightning-combobox label={LABEL.PRODUCTNUMBER} placeholder={LABEL.PRODUCTNUMBER} value="NAmnea 231e" options={productNumberOptions} required onchange={handleProductChange}></lightning-combobox>
</lightning-layout-item>