0

I want to add the icon & change the text color to Red on condition.But getting the error-'Error retrieving data TypeError: Cannot add property statucBadgeColor, object is not extensible'.

Please find the JS code for LWC-

const PARTNERTASKCOLUMN = [
{label: columnHeader1,
    type: 'text',
    hideDefaultActions: true,
    fieldName: 'Name',
    // typeAttributes: {label: {fieldName: 'offeringTitle'}, target: '_self'},
    sortable: true
},
{label: columnHeader3,
    type: 'text',
    hideDefaultActions: true,
    fieldName: 'Status__c',
    sortable: true
}
{label: columnHeader5,
    type: 'date',
    hideDefaultActions: true,
    // fieldName: 'Due_Date__c',
    sortable: true,
    typeAttributes: {
        value: { fieldName: 'Due_Date__c' },
        iconColor: { fieldName: 'statusBadgecolor' },
        icon: { fieldName: 'statusIconName' },
        textColor: { fieldName: 'statusBadgecolor' }
    }
}   

]

const DUEDATECONDITIONALFORMATTINGPROEPRTIES =[
{
    date: todayDate,
    textColor: 'red',
    iconName: 'utility:warning'
}

]

const ERROR_LABEL = 'error';

export default class OfferingListView extends LightningElement {
myTaskWrappers;
columnIsSortableDefault= true;
hideColumnDefaultActionsDefault= true;
recordsPerPage= 2;
displayRowSelector= true;
searchableColsList=[true, true , true, true , true];

columns = PARTNERTASKCOLUMN;

hideViewButton = true;
hideEditButton = true;
hideDeleteButton = true;
selectedRecord=null;
isLoading = false;

// Labels for UI
label = {
    homeLabel,
    myTasksHeader,
    viewButton,
    dismissTaskButton,
};

connectedCallback(){
    loadStyle(this, listViewCSS)
        .then(() => console.log('ListViewCSS Styles loaded.'))
        .catch(error => console.log("Error " + error.body.message));

        getMyPartnerTask()
        .then((result)=>{
            console.log('RESULT  '+result);
            this.myTaskWrappers = (result);
            this.myTaskWrappers = result.map(wrapper => wrapper.mtask);
            console.log('Called conditional');
            this.setConditionalFormatting();
            console.log('GONE');

            // this.myTaskWrappers = result.map(wrapper => wrapper.mtask);
            console.log('MY TASK WRAPPER '+this.myTaskWrappers);
        })
        .catch(error => {
            console.error('Error retrieving data '+error);
        });
    }

    setConditionalFormatting(){
        if(this.myTaskWrappers){
            console.log('1');
            this.myTaskWrappers = this.myTaskWrappers.map(item => {
                console.log('2');
                console.log('today '+ todayDate);
                console.log(item.Due_Date__c);
                if(item.Due_Date__c){
                    console.log('3');
                        console.log('111 '+DUEDATECONDITIONALFORMATTINGPROEPRTIES.some(format => format.date > item.Due_Date__c));
                        if(DUEDATECONDITIONALFORMATTINGPROEPRTIES.some(format => format.date > item.Due_Date__c)){
                             item.statusBadgecolor = DUEDATECONDITIONALFORMATTINGPROEPRTIES.find(format => format.date > item.Due_Date__c).textColor;
                             console.log('5');
                             item.statusIconName = DUEDATECONDITIONALFORMATTINGPROEPRTIES.find(format => format.date > item.Due_Date__c).iconName;
                            // console.log('6');
                            //item.statusIconName = 'utility:warning';
                            console.log('6');
                        }
                }
            }
                )
        }
    }

0

You must log in to answer this question.

Browse other questions tagged .