7

JavaScript

 async connectedCallback() {
    this.isLoaded=true;
    await this.ScrollToTop();
    let result = await getLocationwithKeys({});
    this.LocationAllData =await this.filterCountData(result);
    console.log('this.LocationAllData....' + JSON.stringify(this.LocationAllData));
    this.isLoaded=false;
}

async filterCountData(result) {
    for (let i = 0; i < result.length; i++) {
        let count = 0;
        if (result[i].VFD_Datas__r)
            count = count + result[i].VFD_Datas__r.length;
        if (result[i].Existing_Keys__r)
            count = count + result[i].Existing_Keys__r.length;
        if (result[i].Refrigeration_Data_Tables__r)
            count = count + result[i].Refrigeration_Data_Tables__r.length;
        if (result[i].Add_Sensors_Data__r)
        count = count + result[i].Add_Sensors_Data__r.length;
        result[i].count = count;
        if(count>0){
            result[i].showrecordy =true;
        }
    }
    return result;
}

error is coming on count and showrecordy as i am adding into array how can i resolve it.

0

1 Answer 1

17

It seems that with Spring 20, the response from apex has become non-extensible with additional parameters.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/preventExtensions

As workaround you can use result = Object.assign({}, result) for objects, or item = Object.assign({}, item) in a loop for each item in result for arrays

Or spread syntax data = { ...result };

Or one more dirty hack is JSON.parse(JSON.stringify(result));

1
  • Does anyone know if this change is documented anywhere? I have a scratch org that is on Winter 20, and a Sandbox that is on Spring 20, so I can verify that something was change, I just want to know why.
    – Ben Nguyen
    Commented Jan 6, 2020 at 21:01

Not the answer you're looking for? Browse other questions tagged .