0

I would like to query all lists across different site collections based on a specific content type, but getting only the last modified item.

Using Rest api and caml query, can be achieved, but that is only for one list and I can't query all site collections as I can do with Search and search applies permissions by default. So I don't have to handle that.

I am using JSOM and this is my code:

var queryText = "ContentTypeId:0x010090F49E2D3AE4F040B1ABFE669D391C31*";

                        var clientContext = new SP.ClientContext.get_current();                     
                        var contextSite = clientContext.get_site();
                        var keywordQuery = new Microsoft.SharePoint.Client.Search.Query.KeywordQuery(clientContext); 
                        keywordQuery.set_queryText(queryText);
                        keywordQuery.set_rowLimit(5000);
                        keywordQuery.set_trimDuplicates(false);
                        keywordQuery.set_enableSorting(true); 
                        var sortproperties = keywordQuery.get_sortList();
                        sortproperties.add("Projectnaam", 0);

                        var filterCollection = keywordQuery.get_refinementFilters();
                        var properties = keywordQuery.get_selectProperties();

Could you please help me figure out how to get the last modified item from each list using Search API?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.