[英]Copy word document between document libraries in different subsites (SharePoint)
What is the best (subjective.. I know. Sorry!) method for prompting a user to copy an instance of a document in my library to a library in his own site (on the same site collection, if that matters)? 什么是提示用户将库中文档的实例复制到自己网站(如果重要的话,在同一网站集上)中的库的最佳(主观..我知道。很抱歉!)方法是什么? I am an administrator with a few word documents that I create too frequently to set specific content types for.
我是一位管理员,我经常创建一些Word文档,以至于无法为其设置特定的内容类型。 So I have created a library that contains a few word templates for them to copy over (most importantly: metadata included except for the modified/created fields).
因此,我创建了一个包含一些单词模板的库,供他们复制(最重要的是:除已修改/创建的字段外,还包含元数据)。
I have tried a few javascript/jquery methods that I'd put on the display form with a text box allowing them to enter their library url and how many copies they'd like to make, but that doesn't seem to work as I'd like. 我已经尝试了一些用文本框显示在显示表单上的javascript / jquery方法,允许他们输入自己的库网址以及他们要制作多少个副本,但这似乎不起作用。想要。 What would be the most efficient way of accomplishing this?
实现这一目标的最有效方法是什么? Using an event handler?
使用事件处理程序? If so, is there any way to associate one of these with a custom button on the ribbon (I've only associated these buttons for js functions)?
如果是这样,是否有任何方法可以将其中之一与功能区上的自定义按钮相关联(我仅将这些按钮与js函数相关联)?
Example of the javascript function I was trying to use: 我尝试使用的javascript函数示例:
function copyItem() {
var itemurl = $("#copyFrom").val();
var dst = $("#copyTo").val();
$().SPServices({
operation: "GetItem",
Url: itemurl,
async: false,
completefunc: function (xData, Status) {
itemstream = $(xData.responseXML).find("Stream").text();
itemfields = "";
$(xData.responseXML).find("FieldInformation").each(function(){
itemfields+=$(this).get(0).xml;
});;
}
});
$().SPServices({
operation: "CopyIntoItems",
SourceUrl: itemurl,
async: false,
DestinationUrls: [dst],
Stream: itemstream,
Fields:itemfields,
completefunc: function (xData, Status) {
var error = $(xData.responseXML).find("CopyResult").first().attr("ErrorCode");
}
}
}
called by: 致电者:
<label>from:</label><input type="text" value="" id="copyFrom" maxlength="255">
<label>to:</label><input type="text" value="" id="copyTo" maxlength="255">
<input type="button" onclick="copyItem();" value="Copy">
note: I am not entering any values into these text boxes right now as I'm manually entering them into itemurl and dst. 注意:我现在没有在这些文本框中输入任何值,因为我正在将它们手动输入到itemurl和dst中。 But the console says:
但是控制台说:
The value of the property 'copyItem' is null or undefined, not a Function object.
属性'copyItem'的值为null或未定义,不是Function对象。
It's not recommended to use "async:false". 不建议使用“ async:false”。 It's better to do an asynchronous call and insert your second
SPServices
into the first one. 最好进行异步调用,然后将第二个
SPServices
插入第一个SPServices
。
Also a close parenthesis is missing for your second SPServices
. 另外,第二个
SPServices
缺少圆括号。
And finally, the "Fields" must be an array ( http://msdn.microsoft.com/en-us/library/copy.copy.copyintoitems.aspx ). 最后,“字段”必须是一个数组( http://msdn.microsoft.com/zh-cn/library/copy.copy.copyintoitems.aspx )。
I tried the below code and it worked for me: 我尝试了下面的代码,它为我工作:
var srcurl="http://my.sharepoint.com/aymeric_lab/Shared%20Documents/879258.jpeg";
var desturl="http://my.sharepoint.com/aymeric_lab/Shared%20Documents/879258_copy.jpeg";
$().SPServices({
operation: "GetItem",
Url: srcurl,
completefunc: function (xData, Status) {
var itemstream = $(xData.responseXML).find("Stream").text();
var itemfields = [];
$(xData.responseXML).find("FieldInformation").each(function(){
itemfields.push($(this).get(0).xml);
});
$().SPServices({
operation: "CopyIntoItems",
SourceUrl: srcurl,
DestinationUrls: [ desturl ],
Stream: itemstream,
Fields:itemfields,
completefunc: function (xData, Status) {
}
})
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.