function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Pratik Raut 14Pratik 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.


 

Pratik Raut 14Pratik Raut 14
@wire(createContract, { recordId: '$recordId'}) contact({ error, data }) {
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
}
}
Raj VakatiRaj Vakati
Can you explain what you are doing here ? and share the code 
Pratik Raut 14Pratik Raut 14
I returning the Wrapper object from Apex Class
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;
            });

 
Pratik Raut 14Pratik Raut 14
@Raj Vakati
I am assigning the value to variable in wrapper class  in Lightning component controller
Anusha MynampatyAnusha Mynampaty
1. Inside the set function, return true.
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.