I have a combo-box in LWC - whose values get populated on load of the page with the help of @wire
. The code is as follows:
@wire(fetchL1ProductValues,{userType:'$userType',accountId:'$recordId'})
productList;
get productOptions(){
console.log('>>>>'+JSON.stringify(this.productList.data));
return this.productList.data;
}
<lightning-combobox
class="l1ProductCmp"
value={l1SelectedValue}
placeholder="-Select-"
options={productOptions}
onchange={onSelectProductL1} >
</lightning-combobox>
onSelectProductL1(event){
this.l1product = event.target.value;
fetchL2ProductValues({productId: this.l1product ,userType:
this.userType})
.then(result => {
//how to transform the result so that i can populate another combo-box with this result
}
The issue I'm facing here is that I am not able to populate the second combo-box with the result which i have obtained in onSelectProductL1
function. Imperative method of calling apex is not working in this scenario. we cannot use @wire
inside a function. What would be the ideal solution to this problem?
fetchL2ProductValues
a custom apex method? Do you want to execute and get the result on change of the combo box? – rahul gawale Jun 13 '19 at 18:19