I have a requirement for a project where the client asks me to return the deleted items after a given timestamp.
/fetch-updates?last-update=[timestamp]
I made some research regarding this but couldn't find anything. From what I know if an item is deleted it can't be traced no more, but I might be wrong.
Is there a way to do that?
If not, could you please suggest a way of doing this operation?
By default when you delete an item in Sitecore it's moved to Recycle bin
. If the item wasn't removed from the recycle bin you can still find the information when it was deleted.
You can check items in recycle bin using the code:
Archive archive = Sitecore.Data.Database.GetDatabase("master").Archives["recyclebin"];
List<ArchiveEntry> itemsRemovedAfterSomeDate
= archive.GetEntries(0, int.MaxValue).Where(entry => entry.ArchiveDate > someDate).ToList();
Remember that the ArchiveEntry.ArchiveDate
property uses UTC
time so you may want to use ArchiveEntry.ArchiveLocalDate
instead.
You can turn off/on Recycle bin
in Sitecore config file:
<!-- RECYCLE BIN
If true, when deleting items in the client, they will
be moved to the recycle bin rather than being deleted
Default value: true
-->
<setting name="RecycleBinActive" value="true" />