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

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



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? 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. 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



enter image description here



Column in Results (as well as all other default fields)



enter image description here




2 Answers
2



We can use the REST API below to get the custom fields from a custom list.


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)





Nice and simple, although won't work for me since I'm using a document library and not a list
– Matt L.
Aug 7 at 13:34





I modify the reply above, you can check it.
– LZ_MSFT
Aug 8 at 1:29





Still getting a Cannot find resource for the request fields. 404 error
– Matt L.
Aug 8 at 14:47


Cannot find resource for the request fields.



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.



In case of SharePoint REST API, SourceId property is not exposed but could be extracted from SchemaXml property


SourceId


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:


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>')

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





What about with using a Document library, since you don't have access to the fields property?
– Matt L.
Aug 7 at 13:33





@MattL. no difference, the same technique applies to library, both list and library resources expose fields and list items
– Vadim Gremyachev
Aug 7 at 16:42





Interesting because I'm getting a 404 error saying Cannot find resource for the request fields.
– Matt L.
Aug 7 at 17:46


Cannot find resource for the request fields.





@MattL., the answer has been updated, apparently this error occurs due to invalid request
– Vadim Gremyachev
Aug 14 at 6:44






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

Creating a leaderboard in HTML/JS