How to detect item recovery in an ItemAdded () event in SharePoint

I know that when an item is recovered from the recycle bin, the ItemAdded event occurs. However, how can I determine if an item has been added from the trash or if it is a new file.

+3
source share
5 answers

You can check the created date of the item. Items from the recycle bin must have a previous created date.

0
source

Items in the cart have a DeletedDate that can be accessed in .BeforeProperties properties

0
source

, : . , , . , . , , .

0

, .

SP2010 properties.AfterProperties , , .

, , , :

if (!properties.AfterProperties.Cast<DictionaryEntry>().Any())
{
    // From Recycle Bin!
}
else
{
    // This item is really new.
}

MOSS SP2013.

0

Check the value of the SPItemEventProperties.ListItemId property:

  • If it is 0, then this is a new element;
  • If it is not 0, then this is the item that is being restored from the recycle bin.
-1
source

Source: https://habr.com/ru/post/1702242/


All Articles