why GetSiteData(query) returns wrong values

烂漫一生 提交于 2020-01-07 04:51:28

问题


I do a caml query on the forms libraries in entire site collection with SPWeb.GetSiteData(SPQuery). For the field "ServerUrl" it returns just "/" instead of "/site name/library name/formName.xml". With item["ServerUrl"] is returns the right value, but i need to use the GetSiteData method.

Here is my code:

SPSiteDataQuery q = new SPSiteDataQuery();
q.Lists = "<Lists ServerTemplate='115' />";
q.Query = "<Where><And><And>"
            + "<Eq><FieldRef Name='" + UserId + "' /><Value Type='Text'>" + User + "</Value></Eq>"
            + "<Geq><FieldRef Name='Created' /><Value Type='DateTime'>" + dateFrom + "</Value></Geq></And>"
            + "<Leq><FieldRef Name='Created' /><Value Type='DateTime'>" + dateTo + "</Value></Leq></And></Where>";
q.Webs = "<Webs Scope='SiteCollection' />";
q.ViewFields =
    "<FieldRef Name='Title' />" +
    "<FieldRef Name='ID' />" +
    "<FieldRef Name='Created' />" +
    "<FieldRef ID='" + officeId + "' />" +
    "<FieldRef ID='" + formStatusId + "' />" +
    "<FieldRef ID='" + accessTypeId + "' />" +
    "<FieldRef Name='ServerUrl' />" +
    "<FieldRef Name='FileRef' />";
ret = web.GetSiteData(q);

回答1:


The seemingly broken ServerURL appears to be just another SharePoint web service funny. If your trying to get the full url for the file then you can build it up from the EncodedAbsUrl and FileRef fields.

http://splucy.wordpress.com/2009/06/02/retrieve-pageurl-in-spsitedataquery/



来源:https://stackoverflow.com/questions/1530335/why-getsitedataquery-returns-wrong-values

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!