I am creating Dependent combo box using refresh apex. The second apex method is being called but in the UI i get an error message as below
I implemented the solution as mentioned in here Can't get refreshApex() to work in lwc but still i get the error. so i wanted a solution.
Here is my code.
import { LightningElement, wire, track } from 'lwc';
import { refreshApex } from '@salesforce/apex';
import getDivisions from
'@salesforce/apex/TrafficReportController.getDivisions';
import getCommunities from
'@salesforce/apex/TrafficReportController.getCommunities';
var commdata;
var commerror;
export default class TrafficHistoryReport extends LightningElement {
@track divisionvalue;
@track communityvalue;
@track Divisionvalues = [];
@track Communityvalues = [];
@track wiredCommunities =[];
@wire(getDivisions)
ListDivisions({data,error}){
if(data){
for(let i=0;i < data.length;i++){
this.Divisionvalues.push({
label: data[i].Name,
value: data[i].Id
});
}
//this.divisionoption = this.Divisionvalues;
}
else if (error){
window.console.log(error);
}
}
@wire(getCommunities, {divId: '$divisionvalue'})
getwiredCommunities(result){
this.wiredCommunities = result;
commdata = result.data;
commerror = result.error;
if(commdata){
this.Communityvalues = commdata.map(record => ({label: record.Name, value: record.id}));
}
else if (commerror){
window.console.log(commerror);
}
}
get divisionoption() {
//console.log(this.Divisionvalues);
return this.Divisionvalues;
}
get communityoption() {
//console.log(this.Divisionvalues);
return this.Communityvalues;
}
onDivisionSelect(event){
//this.divisionvalue = event.target.value;
return refreshApex(this.wiredCommunities);
//event.preventDefault();
//console.log('value'+event.target.value)
}
handlechange(event){
event.preventDefault();
}
}