副本列表从一个列表项到另一个在SharePoint [英] copy list items from one list to another in sharepoint

查看:189
本文介绍了副本列表从一个列表项到另一个在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"

我尝试使用CopyTo从()方法的ItemAdded事件接收器,但想不出弄明白的网址复制到内部的SPListItem。

I tried using the CopyTo() method of an SPListItem inside the ItemAdded event receiver but couldnt figure out the url to copy to.

推荐答案

事实上,正如拉尔斯说,它可以是棘手的移动项目和保留的版本和正确的用户信息。我之前,所以如果你需要一些示例代码,让我知道通过评论,可以与一些指导提供你做与类似的事情。

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://主机/网站/网页/列表/filename.doc

The CopyTo method (if you decide to go with that) need an absolute Uri like: http://host/site/web/list/filename.doc

所以,如果你是在一个事件接收器执行此,你需要concatinate包含所需要的元素的字符串。类似的信息(注意,这可以以其他方式来完成):

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆