简体   繁体   English

如何在Sharepoint REST Api中过滤非标准列

[英]How to Filter for Non-Standard Columns in Sharepoint REST Api

Is it possible to determine which columns in a SP List or document library were custom generated by the user? 是否可以确定用户自定义生成的SP列表或文档库中的哪些列? I'm essentially trying to recreate SharePoint's front end in my app, and I want to add columns to my table just like if the user adds a column in SP. 我实质上是在尝试在应用程序中重新创建SharePoint的前端,并且我想将列添加到表中,就像用户在SP中添加列一样。 My issue is determining which columns are non-standard. 我的问题是确定哪些列是非标准的。

I already know how to get properties for list items/files and I can see my user generated columns in the response. 我已经知道如何获取列表项/文件的属性,并且可以在响应中看到用户生成的列。 I'm just looking for is there a way to filter for only non-standard columns? 我只是在寻找一种仅过滤非标准列的方法吗?

User Generated Column in SP SP中的用户生成列

在此处输入图片说明

Column in Results (as well as all other default fields) 结果中的列(以及所有其他默认字段)

在此处输入图片说明

We can use the REST API below to get the custom fields from a custom list. 我们可以使用下面的REST API从自定义列表中获取自定义字段。

http://sp2013/_api/web/lists/getbytitle('CustomList')/fields?$select=Title&$filter=FromBaseType eq false

For document library use this. 对于文档库,请使用此选项。

http://sp2013/sites/team/_api/web/lists/getbytitle('Documents')/fields?$select=Title&$filter=FromBaseType eq false and Hidden eq false and CanBeDeleted eq true and substringof('SourceID="{',SchemaXml)

I find the most reliable way to determine whether field is built-in or it a custom one is to utilize SPField.SourceId Property : 我发现确定字段是内置字段还是自定义字段的最可靠方法是利用SPField.SourceId属性

Gets either the namespace that defines a built-in field or, if it a custom field, the GUID that identifies the list or Web site where it was created. 获取定义一个内置字段的名称空间,或者如果它是一个自定义字段,则获取标识在其中创建列表或网站的GUID。

In case of SharePoint REST API, SourceId property is not exposed but could be extracted from SchemaXml property 如果使用SharePoint REST API,则不会公开SourceId属性,但可以从SchemaXml属性中提取SchemaXml属性。

The following example demonstrates how to retrieve all the custom fields from a list: 下面的示例演示如何从列表中检索所有自定义字段:

https://site.sharepoint.com/_api/web/lists/getbytitle('<list title>')/fields?$select=InternalName&$filter=substringof('http://schemas.microsoft.com/sharepoint/v3',SchemaXml) eq false

Once the list of field is retrieved, the values of list items could be retrieved by specifying field names in $select expression: 一旦检索到字段列表,就可以通过在$ select表达式中指定字段名称来检索列表项的值:

https://site.sharepoint.com/_api/web/lists/getbytitle('<list title>')/items?$select=<fieldname1>,<fieldname2>

Update 更新

The encountered error 遇到的错误

Cannot find resource for the request fields 找不到请求字段的资源

tells that requested resource(library in this case) could not be found, make sure to provide library title for getbytitle method: 告诉您找不到请求的资源(在这种情况下为 ),请确保为getbytitle方法提供库标题

https://site.sharepoint.com/_api/web/lists/getbytitle('<list title>')

                                                      ^^^^^^^^^^^^^^  

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM