Hi,
I'm trying to get all tasks of the current logged-in user from a site collection using SPSiteDataQuery in SP 2013,but its showing no results.Instead , the results are shown for other list templates like 105(Contacts List) , 101 (Document Lib) etc. but whenever I give servertemplate as 107(Tasks list) , nothing is returned. The tasks list is not having any multiple or Lookup columns and the tasks list is having sufficient data/items to display. I'm not getting any error though , but no data/success. I have tested in visual web-part & in console application but same result.
using(SPSite site = new SPSite("<Server URL>")) { using (SPWeb web = site.OpenWeb()) { SPSiteDataQuery query = new SPSiteDataQuery(); query.Webs = "<Webs Scope=\"SiteCollection\" />"; query.Lists = "<Lists ServerTemplate=\"107\" />"; //query.ViewFields = "<FieldRef Name='AssignedTo' />"; query.Query = "<Where><Gt><FieldRef Name='ID' /><Value Type='Counter'>0</Value></Gt></Where>"; DataTable dtTasks = new DataTable(); dtTasks = web.GetSiteData(query); LogMessage("Row Count := " + dtTasks.Rows.Count,""); grdTasks.DataSource = dtTasks; grdTasks.DataBind(); } }
I have also followed the msdn blog : http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsitedataquery.query.aspx , but no success :(. Also I have tried different combinations in query.ViewFields , query.Lists , query.Query like ( Hidden="true" , type="User","Multi","UserMulti","MultiUser","Text" etc...scope=Sitecollection , recursive) . but nothing is working in my case.
Vipul Jain