从回收站恢复项目时会触发什么事件

发布于 2024-10-01 09:15:52 字数 49 浏览 1 评论 0原文

当项目从回收站恢复到共享点列表时会触发什么事件。以及如何使用属性找到该项目?请帮助我

what event is fired when an item is restored from recycle bin into a sharepoint list. And how to find that item using properties? please help me in this

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

看海 2024-10-08 09:15:52

根据事件接收者内容类型

从回收站恢复会触发所有 ItemAdding 和 ItemAdded 事件,无论内容类型如何

...

我开始看到曙光,尽管我确实认为回收站是一个设计缺陷。请注意如何实现事件接收器。目前,我认为对代码中的内容类型进行额外检查可能是确保您的代码不会意外运行不同内容类型的最安全方法?

也许您可以使用“已创建”字段的值来确定列表项是否确实是新的,或者是否正在从回收站中恢复。

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.

羞稚 2024-10-08 09:15:52

当您从回收站恢复项目时,将触发 ItemAdded 事件。 此答案提供了一些有关如何区分项目是新添加还是恢复的选项。

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.

子栖 2024-10-08 09:15:52

我对此的解决方案:

public override void ItemAdded(SPItemEventProperties properties)
{
    if (!properties.AfterProperties.GetEnumerator().MoveNext())
    {
        //From recycle bin
    }
}

My solution to this:

public override void ItemAdded(SPItemEventProperties properties)
{
    if (!properties.AfterProperties.GetEnumerator().MoveNext())
    {
        //From recycle bin
    }
}
南七夏 2024-10-08 09:15:52

我今天遇到了同样的问题,但我的事件接收器位于 ItemAdding 中,其中 SPItemEventProperties 不包含任何日期。

我认为正确的方法是检查 SPItemEventProperties.ListItemId 属性。如果它是0,那么它是一个新项目。如果它不为 0,则它是从回收站恢复的项目,因为它必须在返回的列表中保留其原始 ID。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文