获取列表的默认列表表单URL,即使它使用的是InfoPath也是如此 [英] Get the default list form URLs for a list, even if it is using InfoPath

查看:65
本文介绍了获取列表的默认列表表单URL,即使它使用的是InfoPath也是如此的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经实现了以下功能,它非常有效地获取特定列表的
默认表单网址。这适用于InfoPath未编辑/触及表单的列表。但是,对于默认表单为InfoPath表单的列表运行函数时,
DefaultDisplayFormUrl DefaultDisplayFormUrl 和$ b从REST API返回的$ b DefaultDisplayFormUrl 值仍包含非InfoPath值。



例如:




  • 对于非InfoPath列表,我得到以下模式:/sites/SITENAME/Lists/LISTNAME/DispForm.aspx ...。
  • 对于InfoPath列表,我仍然得到相同的模式,但它应该像/sites/SITENAME/Lists/LISTNAME/Item/displayifs.aspx ...

 function getListFormUrls(argObj){

var theChildList = argObj.ListName;
var deferred = $ .Deferred();

$ .ajax({
url:_spPageContextInfo.webAbsoluteUrl +" / _ api / web / lists / GetByTitle('" + theChildList +"')/?$ select = DefaultDisplayFormUrl ,DefaultEditFormUrl,DefaultNewFormUrl",
type:" GET",
header:{
" accept":" application / json; odata = verbose",
},
成功:函数(数据){
argObj ['DefaultDisplayFormUrl'] =(data.d.DefaultDisplayFormUrl);
argObj ['DefaultEditFormUrl'] =(data.d.DefaultEditFormUrl);
argObj ['DefaultNewFormUrl'] =(data.d.DefaultNewFormUrl);
deferred.resolve(argObj);

},
error:function(error){
console.log(JSON.stringify(error));
deferred.reject();
}
});

return deferred.promise();
}

getListFormUrls({ListName:" TestList"})。then(function(res){
console.log(res.DefaultDisplayFormUrl);
} );


有谁知道我做错了什么?或者,如果有更好的方法来获取任何列表的真正默认表单URL,包括受InfoPath影响的列表?



我尝试分析从以下位置返回的对象:




  • / _ api / web / lists / LISTNAME
  • / _ api / web / lists / GetByTitle('LISTNAME')/ Forms / Items
  • / _api / web / lists / LISTNAME / GetByTitle('LISTNAME')/ Forms /

    (对于这一个,我成功获取了属于该列表的所有表单的表单URL,包括InfoPath的那些,但没有迹象表明哪一个是默认的。


此时,我甚至愿意让REST API告诉我列表的
表单设置是什么设置的。(是否在InfoPath中创建了默认的SharePoint表单或自定义表单) )。但是我在REST API中找不到如何做到这一点。


解决方案

嗨Marco,


实际上,如果想要使用包含InfoPath表单的Rest API获取默认列表表单,这个Rest Url将实现:

 http:// sp / _api / web / lists / GetByTitle('List2')?


< blockquote> select = DefaultDisplayFormUrl,DefaultEditFormUrl,DefaultNewFormUrl





您可以使用SharePoint Designer检查默认表单并找出xml数据是否正确:


< img alt =""src ="https://social.msdn.microsoft.com/Forums/getfile/1414978">


如果存在所有列表表单,请使用" http: // SP / _api /网络/列表/ GetByTitle( '列表2')/形式/"将列出所有表单,但是这不会指定哪个是具有true / false布尔值的默认表单。


所以在这种情况下,仍然使用第一个url来获取默认的new /编辑/显示表格。


谢谢


最好的问候


I have implemented the function below, which works wonderfully to obtain the default form URLs for a specific list. This works great for lists whose forms have not been edited/touched by InfoPath. However, when running the function against a list who's default forms are InfoPath forms, the DefaultDisplayFormUrl, DefaultDisplayFormUrl, and DefaultDisplayFormUrl values returned from the REST API still contain the non-InfoPath values.

For example:

  • For non-InfoPath lists, I get this pattern: /sites/SITENAME/Lists/LISTNAME/DispForm.aspx...
  • For InfoPath lists, I still get the same pattern, but it should be something like /sites/SITENAME/Lists/LISTNAME/Item/displayifs.aspx...

function getListFormUrls(argObj) {

  var theChildList = argObj.ListName;
  var deferred = $.Deferred();

  $.ajax({
    url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/GetByTitle('" + theChildList + "')/?$select=DefaultDisplayFormUrl,DefaultEditFormUrl,DefaultNewFormUrl",
    type: "GET",
    headers: {
      "accept": "application/json;odata=verbose",
    },
    success: function(data) {
      argObj['DefaultDisplayFormUrl'] = (data.d.DefaultDisplayFormUrl);
      argObj['DefaultEditFormUrl'] = (data.d.DefaultEditFormUrl);
      argObj['DefaultNewFormUrl'] = (data.d.DefaultNewFormUrl);
      deferred.resolve(argObj);

    },
    error: function(error) {
      console.log(JSON.stringify(error));
      deferred.reject();
    }
  });

  return deferred.promise();
}

getListFormUrls({ListName: "TestList"}).then( function(res) {
   console.log(res.DefaultDisplayFormUrl);
});

Does anyone know what I'm doing wrong? Or if there is a better way to obtain the true default form URLs for any list, including InfoPath-affected ones?

I tried analyzing the objects returned from:

  • /_api/web/lists/LISTNAME
  • /_api/web/lists/GetByTitle('LISTNAME')/Forms/Items
  • /_api/web/lists/LISTNAME/GetByTitle('LISTNAME')/Forms/
    (For this one, I successfully get the form URLs for all the forms belonging to the list, including the InfoPath ones, but there is no indication of which one is the default one.

At this point, I would even settle for having the REST API tell me what a list's Form Settings are set to. (Whether it has a default SharePoint form or custom form created in InfoPath).  But I can't find how to do that in REST API.

解决方案

Hi Marco,

Actually, if want to get default list form with Rest API which including InfoPath form applied, this Rest Url will achieve:

http://sp/_api/web/lists/GetByTitle('List2')?


select=DefaultDisplayFormUrl,DefaultEditFormUrl,DefaultNewFormUrl


You could check the default form using SharePoint Designer and find out the xml data is correct:

For all the list form exists, use "http://sp/_api/web/lists/GetByTitle('List2')/Forms/" will list all forms, but this won't specify which is the default form with true/false boolean value.

So in this situation, still use the first url to get the default new/edit/display form.

Thanks

Best Regards


这篇关于获取列表的默认列表表单URL,即使它使用的是InfoPath也是如此的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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