When I am querying lists items via SPSiteDataQuery
by ServerTemplate
, it returns items:
SPSiteDataQuery query = new SPSiteDataQuery();
query.Lists = "<Lists ServerTemplate=\"107\"/>";
query.ViewFields = "<FieldRef Name=\"Title\"/>";
query.Query = "<OrderBy><FieldRef Name=\"Title\"/>";
query.Webs = "<Webs Scope=\"SiteCollection\"/>";
DataTable dt = web.GetSiteData(query);
But when I replace Lists condition to "<Lists><List ID=\"" + listId + "\" /></Lists>"
it returns empty datatable.
listId
is correct, List exists in child site of web.
Where I am wrong?
"<Lists><List ID=\"" + lib.Id.ToString("D").ToUpper() + "\"/></Lists>"
. Result Lists string is:"<Lists><List ID="9027A315-0B24-4278-BC54-8C6D6BBC8C85"/></Lists>"
. I've checked list, it has same id and there is one task in this list. But result is still empty.