I have two js methods in my js file.
One methods fetches a set of fields from an particular object, using an apex class method.
@wire(getSObjectFieldNames , { sObjectName : 'Contact' })
sObjectFieldNames({ error, data }) {
if (data) {
this.sObjectFieldDetails = data;
for(let fieldLabel in data){
this.mapOfFieldLabelsWithAPI.push({fieldName:fieldLabel, label:data[fieldLabel]});
this.columns = this.mapOfFieldLabelsWithAPI;
}
this.error = undefined;
} else if (error) {
this.error = error;
this.data = undefined;
}
}
The second method should pass the set of fields - fetched from the previous method as parameter to another apex class - method and should fetch a record list having those field details
@track error;
@track sObjectList ;
@wire(setSObjectRecordList , { sObjectName : 'Contact',
sObjectFieldList : this.columns})
sObjectRecordList({error, data }) {
console.log( "*********");
if (data) {
console.log("__________"+JSON.stringify(this.columns));
this.sObjectList = data;
} else if (error) {
this.error = error;
}
}
My problem here is that for the second method this.columns is coming as undefined, so the second method is throwing an error :
**Cannot read property 'columns' of undefined**