Hello,
I'm trying to use "change data.type === 'delete'. As I saw in the "Handle Cange Event" chapter, * itemId — returns the ID of the changed item. I desume also the ID of the delete item but I get an undefined value.
Is this the aspected behaviour? I need to get this ID to update some data in another list using pop
Hi @Fritz77,
There might be several deleted items, so their IDs are put into itemIds
.
Sorry but in Plumsail documentation you can find this:
Execute a function when a control value has been changed. changeData passed as an argument to the handler. It is an object that contains information about the changes made:
- type — returns type of changes made to related items.
- ‘add’ — new item has been created
- ‘addFolder’ — new folder has been created
- ‘edit’ — item has been changed
- ‘delete’ — item/file has been deleted
- ‘upload’ — file has been uploaded
- itemId — returns the ID of the changed item
- itemIds — returns the array of IDs of the uploaded files
I haven't any uploaded files but just a list item
Hi @Fritz77,
Seems like the article in the documentation is outdated, thanks for pointing it out!
Here's a working snippet of code that shows an alert with the IDs of the deleted items:
fd.spRendered(function() {
fd.control('ListOrLibrary1').$on('change', function(changeData) {
if (changeData.type === 'delete') {
alert(changeData.itemIds);
}
});
});
Thank you!
so it returns an array and I've to use an items.foreach... Correct?
Hi @Fritz77,
Yes, itemIds is an array of numbers. You can either use itemIds.foreach() or a simple for loop:
for (let i = 0; i < changeData.itemIds.length; i++) {
alert(changeData.itemIds[i]);
}