You need to sign in to do that
Don't have an account?
Lightning Datatable: How do you save values to database using draftvalues?
I'm using the Lightning Datatable component as an editable table.
When I click the Save button I am able to retrieve the draftValues however the record Id's are not stored, only the row id of the table, for example id=row-1.
So when I call my Apex controller to save the values I get the exception:
FATAL_ERROR|System.DmlException: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: []
When I click the Save button I am able to retrieve the draftValues however the record Id's are not stored, only the row id of the table, for example id=row-1.
So when I call my Apex controller to save the values I get the exception:
FATAL_ERROR|System.DmlException: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: []
It was because in my component I had keyfield set to lowercase "id" instead of uppercase "Id"
<lightning:datatable
aura:id="dtTable"
columns="{! v.columns }"
data="{! v.data }"
keyField="Id"
errors="{! v.errors }"
draftValues="{! v.draftValues }"
onsave="{! c.handleSaveEdition }"
/>