如何在SharePoint文档库中强制添加/上载文件签出 [英] How to force file checkout on add/upload in a SharePoint Document Library
问题描述
当我尝试在具有必填字段的库上通过JSOM或REST api在SharePoint上传或添加文件时,我的文件未检出。
我已经尝试上传然后以编程方式检出文件,但在这种情况下版本增加。
var fileCollectionEndpoint = spAppWebUrl +" / _ api / sp.appcontextsite(@target)/ web / getfolderbyserverrelativeurl('" + folderRelativeUrl +"')/ files" +" / add(overwrite = true,url ='" + fileName +"')?@ target ='" + targetSiteUrl +"'" ;;
$ .ajax({
url:fileCollectionEndpoint,
type:" POST",
data:arrayBuffer,
processData:false,
header:{
" accept":" application / json; odata = verbose",
" X-RequestDigest":GetDigest()
},
成功:function(data){
var restSource = spAppWebUrl +" / _ api / SP.AppContextSite(@target)/ web / getfolderbyserverrelativeurl('" + folderRelativeUrl +"')/ files / getbyurl(url =' " + data.d.ServerRelativeUrl +"')/ checkout?@target ='" + targetSiteUrl +"'" ;;
$ .ajax({
'url ':restSource,
'方法':'POST',
'标题':{
'接受':'application / json; odata = verbose',
'内容 - 输入':'application / json; odata = verbose',
'X-RequestDigest':GetDigest()
},
'成功':onSuccess,
'错误':onFail
});
},
错误:onFail
});
我想在版本1的签出状态下上传文件,但在结账后,标签版本是2.0。
那么有一种方法可以像在SharePoint上使用必填字段一样上传吗?
这里你去
https://sharepoint.stackexchange.com/questions/200565/how-to-upload-a- file-with-new-version-usign-shareoint-rest-api
https://www.c-sharpcorner.com/UploadFile/anavijai/how-to-enable-force-退房换的文档库式-SH /
When i try to upload or add a file in SharePoint via JSOM or REST api on a library with mandatory field my file is not checked out.
I already tried to upload then checkout the file programmatically but in this case the version is incremented.
var fileCollectionEndpoint = spAppWebUrl + "/_api/sp.appcontextsite(@target)/web/getfolderbyserverrelativeurl('" + folderRelativeUrl + "')/files" + "/add(overwrite=true, url='" + fileName + "')?@target='" + targetSiteUrl + "'";
$.ajax({
url: fileCollectionEndpoint,
type: "POST",
data: arrayBuffer,
processData: false,
headers: {
"accept": "application/json;odata=verbose",
"X-RequestDigest": GetDigest()
},
success: function (data) {
var restSource = spAppWebUrl + "/_api/SP.AppContextSite(@target)/web/getfolderbyserverrelativeurl('" + folderRelativeUrl + "')/files/getbyurl(url='" + data.d.ServerRelativeUrl + "')/checkout?@target='" + targetSiteUrl + "'";
$.ajax({
'url': restSource,
'method': 'POST',
'headers': {
'accept': 'application/json;odata=verbose',
'content-type': 'application/json;odata=verbose',
'X-RequestDigest': GetDigest()
},
'success': onSuccess,
'error': onFail
});
},
error: onFail
});
I would like to upload file in a check out state for the version 1, but after the checkout, the label version is 2.0.
So is there a way to act like SharePoint does on upload in a library with mandatory field?
Here you go
https://sharepoint.stackexchange.com/questions/200565/how-to-upload-a-file-with-new-version-usign-shareoint-rest-api
https://www.c-sharpcorner.com/UploadFile/anavijai/how-to-enable-force-check-out-for-the-document-library-in-sh/
这篇关于如何在SharePoint文档库中强制添加/上载文件签出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!