如何检测 SharePoint 上 ItemAdded() 事件的项目还原
我知道当从回收站恢复项目时,会触发 ItemAdded 事件。 但是,如何检测添加的项目是否来自回收站或者是否是新文件。
I know that when an item is restored from the recycle bin, the ItemAdded event is fired.
However, how can I detect if the item added comes from the recycle bin or if it is a new file.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
检查 SPItemEventProperties.ListItemId 属性的值:
从回收站恢复。
Check the value of the SPItemEventProperties.ListItemId property:
that is restored from the Recycle Bin.
如果您想手动检测它,请检查文档的属性:创建的数据不同。 对于一个文档来说,即使它被扔进回收站,创建的数据也是一样的。
如果您想通过某种工作流程来完成此操作,则可以将属性设置为基准。 更详细的请自行查找。
If you want detect it manually, then check the property of the document: there created data is different. For a document even if it was thrown into recycle bin the created data is the same.
If you want do it through kind of workflow then you can set property as a benchmark. more detail please find it yourself.
回收站中的项目具有可在属性中找到的DeletedDate。BeforeProperties
Items in the recycle bin have a DeletedDate that may be available in the properties.BeforeProperties
您可以检查该项目的创建日期。 回收站中的项目应具有先前的创建日期。
You could check the Created Date of the item. Items from the Recycle bin should have a previous created date.
这是一个非常古老的线程,但它出现在该主题搜索的顶部结果中。
根据我对 SP2010 的实验,它看起来像 properties.AfterProperties<当项目来自回收站时 /a> 为空,而在实际的新项目上它已完全填充。
因此,像这样的简单块就可以解决问题:
我还没有测试过 MOSS 或 SP2013。
This is a very old thread, but it comes up in the top results for searches on the topic.
From my experiments with SP2010, it looks like properties.AfterProperties is empty when the item is coming from the Recycle Bin, whereas it is fully populated on an actual new item.
So, a simple block such as this would do the trick:
I have not tested MOSS or SP2013 yet.