1

Apologies if REST isn't the right tool I need here.

I currently have dozens of content query webparts all over our site. These pull in files from a single library which match a certain metadata which is an AND statement over a max of 3 columns. I then using custom columns to bring in a custom image as well (like a pdf icon logo, or Word icon logo) to make it look nice.

This works well enough, but can be buggy and laggy and slow to make pages. It seems that REST can also help here, but I have NO idea how to even start my journey to obtain it.

I assume the end game would be to have a chunk of custom code, which I can paste in all over the place and it will pull a list of files from our main library just like that webpart does.

Is this all possible? And if so, how can I achieve it?

2 Answers 2

0

If you have exhaustively searched for how to utilized the CQWP web part (e.g. https://www.spguides.com/content-query-web-part-sharepoint-online/), then you can have a solution that does not make use of scripted customizations.

But if that does not work for you, a solution not using the CQWP is possible using REST requests.

Much of my work on SharePoint "solutions" involves REST requests to GET and POST column metadata to items in lists and libraries, including GETing and POSTing files/blobs to (document) libraries. I basically have a snippet of the jQuery AJAX request and set success() and error() callbacks to get the JSON responses, which then can be delivered to other functions that build/alter content in the page.

All your script functions (including the REST request code) in that web part page goes into one (or more) organized Script Editor Web Part (SEWP). Then a separate web part (Content Editor Web Part of HTML Form Web Part) for just the HTML markup alone is placed in the web part page (available through classic experience). Your REST requests read and write to and from the apps (lists, libraries) with JSON-formatted content. You then interact with the HTML web part with standard DOM function calls in your script to manipulate the elements to display your results.

0

SharePoint Rest document for your reference:
Working with lists and list items with REST
Working with folders and files with REST

When you want to use some column values to filter items, you can use the filter keyword, you can use select to get the value of the specified column.
Use OData query operations in SharePoint REST requests

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.