SharePoint:唯一的列值

发布于 2024-08-25 15:44:28 字数 463 浏览 5 评论 0原文

我只想在 SharePoin 列表中包含唯一值。为了实现这一点,我可以使用“ItemAdding”事件处理程序,如下面的链接所述。

http://weblogs.asp.net/vikram/archive/2008/12/24/sharepoint-using-event-handler-to-make-a-column-unique.aspx

现在我有一个疑问:假设两个用户尝试同时在列表中添加具有相同列值(需要唯一值)的列表项。两个调用都会同时触发 ItemAdding 事件吗?如果是这样,则该列中的两个项目可能具有相同的值。请确认。

I Want to have only unique values in a SharePoin List. To achieve this I can use 'ItemAdding' event handler as mentioned in the below link.

http://weblogs.asp.net/vikram/archive/2008/12/24/sharepoint-using-event-handler-to-make-a-column-unique.aspx

Now I have a Doubt: Suppose that two user tries to add list Item in the list with the same column value(which requires unique value) at the same Time. will ItemAdding event would be fired at the same time for both call? If so then there is a possibility that two items having same value in the column. Please confirm.

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

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

发布评论

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

评论(2

一曲琵琶半遮面シ 2024-09-01 15:44:28

我认为,这种方法只允许您在列中拥有半唯一值。也就是说,如果一切都是正常的,那么它就会是独一无二的。但是,您无法比较同时添加的两个项目的属性(是的,这可能会发生,因为 IIS Web 服务器是多线程的)。因此,您可能会得到重复的值。

解决方法 - 也实现“ItemAdded”事件处理程序,并删除新添加的项目(如果它具有与其他现有项目相同的属性)。当然,这种情况很少发生。

I think, this method allows you only to have semi-unique values in the column. That is, if everything is normal, it will be unique. However, you cannot compare the properties of two items being added simultaneously (and yes, it may happen, since IIS web server is multi-threaded). Hence you might have duplicate values as a result.

A workaround - implement a "ItemAdded" event handler, too and delete a newly added item, if it has that property the same as some other existing item. This will, of course, happen very rarely.

美胚控场 2024-09-01 15:44:28

如果您有足够多的并发用户,这可能会成为问题,那么 SharePoint 可能不是适合该工作的工具。如果价值是由用户创造的,那么两个用户同时添加相同价值的可能性极小。如果它是自动生成的,您可能应该使用基于 ID 的东西,众所周知,ID 是唯一的。

如果您无论如何都担心重复的可能性,只需确保在最终出现重复导致问题时可以编辑该字段即可。

If you have enough concurrent users that this is likely to be a problem, SharePoint probably isn't the right tool for the job. If the value is created by the user, it is extremely unlikely that two users will be adding the same value at the same time. If it is automatically generated, you probably should be using something based on ID, which is known to be unique.

If you are worried about the possibility of duplicates anyway, just make sure that the field can be edited if you do end up with duplicates causing problems.

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