0

I already created a webpart which getting all tasks from current user cross-site. It works and I see the same tasks as in the task list on my mysite. I only see the tasks list in my webpart is not getting the latest tasks. It gets only the tasks which are loaded in the mysite task list.

When I go to the mysite task list I see it is refreshing and gets the latest tasks. So there is some logic on this page which is forcing getting all tasks.

How can I do the same in my webpart code?

private void ShowMyTasks()
        {
            // Get current context
            var context = Microsoft.SharePoint.SPServiceContext.Current;

            // Gets the session manager
            UserSettingsManager usm = new UserSettingsManager(context);
            Microsoft.Office.Server.WorkManagement.UserOrderedSessionManager osm = new UserOrderedSessionManager(context);

            UserOrderedSession uos = osm.CreateSession();

            // Create a new task query
            Microsoft.Office.Server.WorkManagement.TaskQuery tq = new TaskQuery();

            // Set completed filter
            var taskFilter = new TaskFilter()
            {
                CompletedCriterion = new BooleanCriterion() { CompareType = BooleanCompareType.IsFalse }
            };

            tq.FieldFilter = taskFilter;

            // Read filtered tasks from the task session

            TaskClientCollection tcc = uos.ReadTasks(tq);

            // Set datasource and bind
            taskRepeater.DataSource = tcc;
            taskRepeater.DataBind();
        }

1 Answer 1

0

It is way too much code to simply copy&paste it into here, so please check this Microsoft link which hopefully will remain in place and see the section: "Working with provider refreshes". This should offer you the functionality to refresh the tasks.

1
  • Do I missing this code?? CreateRefreshJobResult refreshResult = uos.BeginCacheRefresh();
    – Ola
    Jun 10, 2015 at 11:46

Your Answer

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

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