I am querying multiple task lists in a SharePoint site. I can retrieve the results until I set the Query
property and specify the OrderBy clause. The detailed exception and code is pasted below. Appreciate any help
private void doTasks(SPWeb currentWeb, SPSiteDataQuery q)
{
q.Query =
"<OrderBy>" +
" <FieldRef Name='Priority' />" +
" <FieldRef Name='DueDate' />" +
"</OrderBy>";
// Specify the view fields.
q.ViewFields = "<FieldRef Name='Title' Type='Text'/>";
q.ViewFields += "<FieldRef Name='AssignedTo' Type='User' Nullable='TRUE' />";
q.ViewFields += "<FieldRef Name='PercentComplete' Type='Number' Nullable='TRUE'/>";
results = currentWeb.GetSiteData(q);
if (results.Rows.Count > 0)
{
//blah!
}
}
[COMException (0x80020009): 0x80020009] Microsoft.SharePoint.Library.SPRequestInternalClass.CrossListQuery(String bstrUrl, String bstrXmlWebs, String bstrXmlLists, String bstrXmlQuery, ISP2DSafeArrayWriter pCallback, Object& pvarColumns) +0 Microsoft.SharePoint.Library.SPRequest.CrossListQuery(String bstrUrl, String bstrXmlWebs, String bstrXmlLists, String bstrXmlQuery, ISP2DSafeArrayWriter pCallback, Object& pvarColumns) +174
[SPException] Microsoft.SharePoint.SPGlobal.HandleComException(COMException comEx) +27428978 Microsoft.SharePoint.Library.SPRequest.CrossListQuery(String bstrUrl, String bstrXmlWebs, String bstrXmlLists, String bstrXmlQuery, ISP2DSafeArrayWriter pCallback, Object& pvarColumns) +27812419 Microsoft.SharePoint.SPWeb.GetSiteData(SPSiteDataQuery query) +521 StoraEnso.Collaboration.WebParts.SubSiteItemAggregator.SubSiteItemAggregator.doTasks(SPWeb currentWeb, SPSiteDataQuery q) +189 StoraEnso.Collaboration.WebParts.SubSiteItemAggregator.SubSiteItemAggregator.Render(HtmlTextWriter writer) +441 Microsoft.SharePoint.WebPartPages.SPChrome.RenderPartContents(HtmlTextWriter output, WebPart part) +43
[WebPartException] Microsoft.SharePoint.WebPartPages.SPChrome.RenderPartContents(HtmlTextWriter output, WebPart part) +19826502 Microsoft.SharePoint.WebPartPages.SPChrome.RenderWebPart(HtmlTextWriter output, WebPart part) +64 Microsoft.SharePoint.WebPartPages.WebPartZone.RenderZoneCell(HtmlTextWriter output, Boolean bMoreParts, WebPart part) +1997 Microsoft.SharePoint.WebPartPages.WebPartZone.RenderWebParts(HtmlTextWriter output, ArrayList webParts) +508 Microsoft.SharePoint.WebPartPages.WebPartZone.Render(HtmlTextWriter output) +1000 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +240 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +240 System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +42 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +240 System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +253 System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +87 System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) +53 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +240 System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +42 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +240 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +240 System.Web.UI.Page.Render(HtmlTextWriter writer) +38 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4240