0

I'm building an LWC for the flow as screen component. The data comes from an invockable class (action) which returns a list of Accounts which has not been created yet.

The invockable class returns something like this:

Account acc1 = new Account();
acc1.Name = 'Account 1';

Account acc2 = new Account();
acc2.Name = 'Account 2';

Account acc3 = new Account();
acc3.Name = 'Account 3';

List<Account> returnAcc = new List<Account>();
returnAcc.add(acc1);
returnAcc.add(acc2);
returnAcc.add(acc3);

return returnAcc;

These are then stored in a Account record variable in the flow.

and then passed to a screen custom component that displays a lightning datatable and pass the record variable to the component.

I've enabled the inline edit on the datatable:

<template>
    <lightning-datatable
                key-field="id"
                data={accRecs}
                columns={columns}
                show-row-number-column="true"
                hide-checkbox-column="true"
                suppress-bottom-bar="true"
                onrowaction={handleRowAction}
                oncellchange={handleSave}
                >
        </lightning-datatable>
</template>

In javascript, i've made a handler for saving:

handleSave(event) {
     const draft = event.detail.draftValues;
     const dfKeys = Object.keys(draft);
     let data = this.accRecs;

     data.forEach(d => {
        dfKeys.forEach(dfKey => {
            if (typeof d[dfKey] !== 'undefined') {
                d[dfKey] = draft[dfKey];
            }
        });
    });

    this.draftValues = [];

}

But when I edit a cell, it throws an error saying:

proxy set handler returned false for property 'Name'
0

1 Answer 1

0

I see that you have used "draftValues" in your .js but it is missing in your .html.

I believe thhe code should be:

<template>
    <lightning-datatable
                key-field="id"
                data={accRecs}
                columns={columns}
                show-row-number-column="true"
                hide-checkbox-column="true"
                suppress-bottom-bar="true"
                onrowaction={handleRowAction}
                draft - values={draftValues}
                oncellchange={handleSave}
                >
        </lightning-datatable>
</template>
3
  • I did that, but still have the error.
    – Carl Ortiz
    May 3, 2022 at 2:33
  • Just trying to understand that is there any specfic reason why you are using 'oncellchange' instead of the 'onsave'?
    – Night Guy
    May 3, 2022 at 5:26
  • I've used both and still get the same error.
    – Carl Ortiz
    May 3, 2022 at 5:27

You must log in to answer this question.

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