Migration onEntryChange in v2.11.0
In our new SDK version 2.11.0, we've improved our onEntryChange
cleaning function to allow you to further tailor your customer experience to your specific use case.
Key Changes
onEntryChange
- In the "Review Entries" step
onEntryChange
is now executed per single entry change but only once for bulk changes like “replace all”, drag or copy and paste - It's triggered if:
- A row is created through
- manual input
- drag
- copy and paste
- pressing the "+" button
- duplication
- A row is deleted
- A row is edited through
- find & replace
- manual input
- drag
- copy and paste
- If undo/ redo leads to above events
- A row is created through
- With the new rows object, you can access all changed rows with their old and new values as well as their indices
- You can also access the type of change via the
actionType
- Edit (manual input; copy and paste; drag and drop)
- Delete
- Replace (row changed via find & replace)
- Create (manual input; copy and paste; drag; "+" button; duplication)
- In the new return object, you can update other rows whether they were changed or not, using the row index
onEntryInit
- As it does today,
onEntryInit
iterates through every imported entry - You can access a row and its index
- As it is today,
onEntryInit
is executed once after thecolumnHooks
callback - It's not executed when a row is created anymore
How to update your implementation?
Update the function parameters
NEW
onEntryChange = (rows) => {};
OLD
onEntryChange = (row, rowIndex, options) => {};
The new syntax
NEW: array of all rows that changed
rows = [
{
rowIndex: number,
data: {},
changeLog: {},
actionType: string // "edit", "create", "delete", "replace"
},
...
]
OLD: row object
row = {
first_name: "New Name",
last_name: "Smith",
company_domain: "wwww.getnuvo.com",
...
}
New properties of the row object
data
= contains the whole row
data = {
first_name: "New Name",
last_name: "Smith",
company_domain: "wwww.getnuvo.com",
...
}
changeLog
= contains the old values of the entries that changed in a row
- If
actionType
is "create", it'snull
- If
actionType
is "delete", it contains the whole row
changeLog = {
first_name: "Old Name",
};
Update the return statement
return [
{
rowIndex: number,
data: {},
changeLog: {}, // optional
actionType: string // optional
},
...
]
For more details, check out our documentation for onEntryChange
and onEntryInit