0

I have about 15 project sites sitting under a root site in O365,each project site has a list called 'Tasks' I would like to display all the tasks on the root site showing

  • Project site the task has came from
  • task name
  • start date
  • user who it is assigned to

I am trying to use the content query web part but it is looking like I may need to download the wp and make changes to it to show the fields I want. I thought before I go down that route why not try REST API's, has anyone done this, suggestions on where to start or could point me in the right direction?

Thanks Jamie

1

Add a new result source at your site collection level, configure search query in that result source to retrieve items related to "Task" content type. Copy the result source id. use REST search api to get the items from that result source, Or just create a search result webpart with result source. and implement display templates to customize the look and feel.

0

It's very easy. You only need call an ajax request:

var restURL = _spPageContextInfo.siteAbsoluteUrl + "/<<subsite>>" + 
"/_api/web/lists(guid'<<guidlist>>')/items" +
"?$select=" + 
"&$filter=" + 
"&$top=999999";

$.ajax({
    dataType: "json",
    type: "GET",
    headers: {
        "accept": "application/json;odata=verbose",
    },
    url: restURL
}).done(function(data) {
    //work with data.d.results

}).fail(function() {

});

You can see the oData possibilities in the link: https://msdn.microsoft.com/en-us/library/office/fp142385.aspx

But you can't do one request to all 15 subsites, you need make one request for each subsite and work with the results in the JavaScript.

  • 3
    Wouldn't it be more efficient to use the search end point and look at tasks rather than iterating through every site looking for every task list? What happens when a user adds a new subsite? – Eric Alexander Aug 3 '15 at 17:29
  • Plus the built-in search web parts eliminates the need for any custom code. – wjervis Aug 3 '15 at 19:00
0

Thanks everyone for your responses

I realised that a CSWP would be good idea after reading your responses.

I gave this a try and removed the filter of assigned to Custom task display template which pulled all tasks from subsites of my root site and made the look and feel better.

All I need to do now is try and group by project but feel that is a different question to this what I originally asked so if I cannot figure it out I'll post a new question.

Thanks Jamie

Your Answer

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

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