You need to sign in to do that
Don't have an account?
Pratik Raut 14
Lightning Web Component getting Error
In Lightning Web Component Controller "TypeError: 'set' on proxy: trap returned falsish for property 'displayTab' "
getting an error when going to set any value to attribute in data that return by Apex Method.Any solution on this.
if (data) {
var dataNew = data;
for(let i in dataNew.allTabsNameWrpList){
console.log('displayTab '+dataNew.allTabsNameWrpList[i].displayTab); //It displaying value of displayTab
dataNew.allTabsNameWrpList[i].displayTab = false; //while going to set it throwing above error
}
}
public with sharing class SurveyDetailController {
@AuraEnabled
public static QuestionOptionWrapper getaddOption(QuestionOptionWrapper queWrapObj){
System.debug('queWqueWrapObjra '+queWrapObj.optList);
System.debug('queWqueWrapObjra '+queWrapObj.optList.size()+1);
VOC_Option__c opt = new VOC_Option__c();
opt.Option__c = '';
Integer var = queWrapObj.optList.size()+1;
String optSr = 'Option '+var ;
OptionWrapper op = new OptionWrapper(opt,optSr );
queWrapObj.optList.add(op);
System.debug('queWrapObj '+queWrapObj);
return queWrapObj;
}
public class QuestionOptionWrapper{
@AuraEnabled public Survey_Question__c question {get;set;}
@AuraEnabled public List<OptionWrapper> optList {get;set;}
@AuraEnabled public Integer qSrNo {get;set;}
}
public class OptionWrapper{
@AuraEnabled public VOC_Option__c option {get;set;}
@AuraEnabled public String sr {get;set;}
public OptionWrapper(VOC_Option__c option,String sr){
this.option = option;
this.sr = sr;
}
public OptionWrapper(){
}
}
}
Controller.js
getaddOption({queWrapObj})
.then(result => {
//alert('LWC result yyy '+JSON.stringify(result));
this.items = result;
for(let i in result){
result[i].qSrNo = i;
}
})
.catch(error => {
this.items = undefined;
});
I am assigning the value to variable in wrapper class in Lightning component controller
2. Remove any wired methods used on the same apex method which is feeding data to the set variable.
3. Remove cacheable=true from the apex method.
This worked for me.