what event is fired when an item is restored from recycle bin
what event is fired when an item is restored from recycle bin into a sharepoint list. And开发者_如何学C how to find that item using properties? please help me in this
According to Event Receivers on Content Types:
Restoring from the Recycle Bin triggers all ItemAdding and ItemAdded events regardless of Content Type
...
I’m starting to see the light although I do think that the Recycle Bin thing is a design flaw. Be careful on how you implement Event Receivers. Currently I’m thinking an additional check on Content Type in your code might be the safest way to ensure your code doesn’t run accidentally for a different Content Type ?
Maybe you can use the value of the Created field to determine if the list item is truly new or if it's being restored from the recycle bin.
ItemAdded Event is fired when you restore an item from Recycle bin. This Answer provides few option on how you could differentiate between if the items is newly added or restored.
My solution to this:
public override void ItemAdded(SPItemEventProperties properties)
{
if (!properties.AfterProperties.GetEnumerator().MoveNext())
{
//From recycle bin
}
}
I faced the same issue today, but my event receiver was in ItemAdding where the SPItemEventProperties does not contain any date.
I think the right way of doing this is to check the value of the SPItemEventProperties.ListItemId property. If it is 0, then it is a new item. If it is not 0, then it is an item that is restored from the Recycle Bin as it has to keep it's original ID in the list it returns to.
精彩评论