将列表项从一个列表复制到 sharepoint 中的另一个列表 [英] copy list items from one list to another in sharepoint
问题描述
在 Sharepoint 中,如何将列表项从一个列表复制到另一个列表例如从列表 A"复制到列表 B"(两者都位于站点的根目录)
In Sharepoint how can you copy a list item from one list to another list eg copy from "List A" to "List B" (both are at the root of the site)
我希望在将新列表项添加到列表 A"时进行此复制
I want this copying to occur when a new list item is added to "List A"
我尝试在 ItemAdded 事件接收器中使用 SPListItem 的 CopyTo() 方法,但无法找出要复制到的 url.
I tried using the CopyTo() method of an SPListItem inside the ItemAdded event receiver but couldnt figure out the url to copy to.
推荐答案
确实如 Lars 所说,移动项目、保留版本和更正用户信息可能很棘手.我之前也做过类似的事情,所以如果您需要一些代码示例,请通过评论告诉我,并可以为您提供一些指导.
Indeed as Lars said, it can be tricky to move items and retain versions and correct userinfo. I have done similar things with that before so if you need some code examples, let me know through a comment and can supply you with some guidance.
CopyTo 方法(如果你决定这样做)需要一个绝对的 Uri 像:http://host/site/web/list/filename.doc
The CopyTo method (if you decide to go with that) need an absolute Uri like: http://host/site/web/list/filename.doc
因此,如果您在事件接收器中执行此操作,则需要连接一个包含所需元素的字符串.类似于(请注意,这可以通过其他方式完成):
So, if you are performing this in an event receiver you need to concatinate a string containing the elements needed. Something like (note that this can be done in other ways to):
string dest=
siteCollection.Url + "/" + site.Name + list.Name + item.File.Name;
这篇关于将列表项从一个列表复制到 sharepoint 中的另一个列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!