Sharepoint 是否通过rest api或jsom更新Infopath表单库值?
是否可以通过rest api或JSOM以编程方式更新infopath表单库字段值?如果有,你能提供一个样品吗 我已经尝试了两种方法,两次都收到了成功消息,尽管在我查看表单的那一刻,我只是尝试更新值,但结果保持不变Sharepoint 是否通过rest api或jsom更新Infopath表单库值?,sharepoint,sharepoint-2013,infopath,sharepoint-jsom,sharepoint-rest-api,Sharepoint,Sharepoint 2013,Infopath,Sharepoint Jsom,Sharepoint Rest Api,是否可以通过rest api或JSOM以编程方式更新infopath表单库字段值?如果有,你能提供一个样品吗 我已经尝试了两种方法,两次都收到了成功消息,尽管在我查看表单的那一刻,我只是尝试更新值,但结果保持不变 <script> //Retrieve list items from sharepoint using API function GetSampleListItems() { siteURL = _spPageContextI
<script>
//Retrieve list items from sharepoint using API
function GetSampleListItems() {
siteURL = _spPageContextInfo.webAbsoluteUrl;
console.log("from top nav - " + siteURL);
var apiPath = _spPageContextInfo.webAbsoluteUrl +"/_api/lists/getbytitle('Training%20Copy')/items/getbyid(9)";
$.ajax({
url: apiPath,
type: "POST",
headers: {
Accept: "application/json;odata=verbose"
},
data: JSON.stringify
({
__metadata:
{
type: "SP.Data.Training_x0020_CopyItem"
},
Position: "Show"
}),
headers: {
"Accept": "application/json;odata=verbose",
"Content-Type": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val(),
"IF-MATCH": "*",
"X-HTTP-Method": "MERGE"
},
async: false, success: function(data) {
alert("Item updated successfully");
}, eror: function(data) {
console.log("An error occurred. Please try again.");
}
})
}
</script>
<button onclick="GetSampleListItems();" type="button">Click me</button>
//使用API从sharepoint检索列表项
函数GetSampleListItems(){
siteURL=\u spPageContextInfo.webAbsoluteUrl;
console.log(“从顶部导航-”+站点URL);
var apiPath=_spPageContextInfo.webAbsoluteUrl+“/_api/list/getbytitle('Training%20Copy')/items/getbyid(9)”;
$.ajax({
url:apiPath,
类型:“POST”,
标题:{
接受:“application/json;odata=verbose”
},
数据:JSON.stringify
({
__元数据:
{
类型:“SP.Data.Training\u x0020\u CopyItem”
},
位置:“显示”
}),
标题:{
“接受”:“application/json;odata=verbose”,
“内容类型”:“应用程序/json;odata=verbose”,
“X-RequestDigest”:$(“#u-RequestDigest”).val(),
“如果匹配”:“*”,
“X-HTTP-Method”:“合并”
},
异步:false,成功:函数(数据){
警报(“项目更新成功”);
},eror:function(data){
log(“发生错误。请重试”);
}
})
}
点击我
我不是程序员,也不懂API,但InfoPath表单库中的文档只是带有奇特扩展名的XML文本文件。InfoPath基本上是一个基于类固醇的XML编辑器。使用任何文本编辑方法都可以更改这些文件中的值,这种方法可以绕过XML层次结构
但是,请注意,在显示或编辑表单中的数据时,可能会使用InfoPath表单界面中的处理逻辑来操作表单中的数据。例如,根据其他字段的值自动设置数据验证或某些字段值。因此,仅仅通过后端对字段值进行黑客攻击可能会导致不期望的结果。这也可能是您没有看到已应用的更改的原因。您可以参考以下文章,通过rest api或JSOM更新listitem值:
嗨,迈克尔,我尝试过这些链接,但都没用。我通过警报框得到确认,但当我查看实际值时,它保持不变。我更新了我的原始问题以包含示例代码