问题
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