In this article I am going to show the various approaches, their pros and cons for showing the tasks assigned to current user across the site collection.
Background: In our SharePoint online portal, we have “MyTasks” web part which was showing the tasks assigned to current user across the site collection. We have implemented this requirement using SandBox solution. So from SandBox solution with the help of Server Side Object model we were querying to Site Collection based on the list type “Task”.
But suddenly news appear, Microsoft has deprecated the SandBox solution and custom SandBox solution will work only for few days (30 days they were saying). So we must need to change the implementation of our SandBox solutions.
So we are trying to find the right approach to implement this requirement and we found few of those, which I will discuss in this article with Pros and Cons of respective approach.
1.OOB Search (Content By Search web part): This is the first default option came to mind. But here only issue time required to update the search index. Minimum crawling time 15 minute and its not confirmed. Crawling may take more time than 15 minutes. Our customer dosent want that time too. If crawling duration is no issue to customer then I feel this is best possible solution to implement.
1. OOB approach available.
2. Very easy to configure.
3. No throttling issue.
4. Formatting result is easy through Display Templates.
Cons: Crawling duration.
2.OOB Content Query webpart (CQWP): This is also one of the finest option. But unfortunately CQWP didn't worked for us. We have multiple task lists in Site Collection and having large number of items available in task lists. CQWP throws throttling exception as shown in following figure 1. So this option also didn't worked for us. If search is not working and If there not much items in Tasks List or only few tasks lists then this OOB solution is preferable.
|Figure 1 : Throttling issue - CQWP|
Pros: OOB approach available. No customization
1. Throwing throttling exception
2. Formatting is not easy. Must require knowledge of XSLT
3.Using JSOM (Java Script Object Model) : This is customized option available. But unfortunately there is no option to query Site Collection using JSOM. There is no API available for querying Site Collection. We can only query to a list at a time. So in this case we need to travel through whole Site Collection and and query to each Task list and aggregate the result.
Pros: We could achieve the result :)
Cons: I am sure this web part will be very slow. Traveling through whole Site Collection and then querying to each Task list and then rendering the result on page, it will be very slow
4.Provider Hosted App: We could implement the Provider hosted app (asp.net / MVC) and host on remote server. Provider hosted app will communicate with Office 365 using Client Side Object Model (CSOM) and show the result.
1. Code will be not executed on our Office 365 environment, it will executed on remote server.
2. Implementation will be easy.
3.Result formatting will be easy.
1. We will need remote server to host the Provider Hosted App.
2. We need to apply our custom master page for same look and feel
3. User will be redirected to out of the Office 365 site
Enjoy Reading :)
Feel free for any comment / suggestion / feedback if any.