0

In SharePoint Online, I have a JavaScript that run on a normal site collection and tries to read data from the user's personal site (more specifically from the WmaAggregatorList_User list).

This fails, likely because the site collection and personal site are different domains (site.sharepoint.com vs site-my.sharepoint.com), thus causing cross origin problems in the browser.

I have tried various ways to read the data (RequestExecutor, JSOM, jQuery Ajax), both through REST and with CAML Query, but nothing works.

Has anyone succeeded in querying the personal site from a normal SharePoint Online site?

  • if you are trying to do this through app than you can have a look at below url blogs.msdn.com/b/officeapps/archive/2012/11/29/… – Amit Feb 6 '15 at 9:16
  • The JavaScript in "injected" on the SharePoint site, so it executes on the SP domain. I've tried RequestExecutor without luck I only get a failed response and a correlation id (that I can not look up since it is SharePoint Online). – rlv-dan Feb 6 '15 at 11:00
2

This could be done with SP.WorkManagement.js , if I understands you correctly.

Example code:

RegisterSod('SP.WorkManagement.js', '/_layouts/15/SP.WorkManagement.js');

SP.SOD.loadMultiple(['sp.js', 'SP.WorkManagement.js'], function() {
        var context = new SP.ClientContext.get_current();
        var userSessionManager = new SP.WorkManagement.OM.UserOrderedSessionManager(context);
        var userSession = userSessionManager.createSession();
        var query = new SP.WorkManagement.OM.TaskQuery(context);
        var myTasks = userSession.readTasks(query);

        $(document).ready(function () {
            getMyTasks();
        });

        function getMyTasks() {
            context.load(myTasks);
            context.executeQueryAsync(onGetMyTasksSuccess, onGetMyTasksFail);
        }

        function onGetMyTasksSuccess() {

            var taskEnumerator = myTasks.getEnumerator();
            while (taskEnumerator.moveNext()) {
                var task = taskEnumerator.current;
                console.log("Task: " + task.get_id() + " - " + task.get_name());
            }
        }

        function onGetMyTasksFail(sender, args) {
            console.log('Failed to get tasks. Error:' + args.get_message());
        }
    });
  • I wonder how this will work now when MS have deprecated Work Management in the cloud – Robert Lindgren Feb 7 '15 at 8:47
  • @RobertLindgren Fair enough hehe, though you'll think they'll remove the aggregated list to if/when that happens :) – Anders Aune Feb 7 '15 at 9:43
  • Yes, the comment was more of a philosophical nature ;) – Robert Lindgren Feb 7 '15 at 10:18
  • @AndersAune Thank you for pointing me in the right direction. I found this page useful for working with WorkManagement.js: MyTasks – The WorkManagement and Task Aggregation JSOM APIs in SharePoint – rlv-dan Feb 9 '15 at 9:02
  • Great, thats actually the same blog post I got my code from a couple of months ago iirc :) – Anders Aune Feb 9 '15 at 20:54

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.