为什么 GetSiteData(query) 返回错误值
我使用 SPWeb.GetSiteData(SPQuery) 对整个网站集中的表单库执行 caml 查询。对于“ServerUrl”字段,它仅返回“/”而不是“/site name/library name/formName.xml”。使用 item["ServerUrl"] 返回正确的值,但我需要使用 GetSiteData 方法。
这是我的代码:
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);
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);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看似损坏的 ServerURL 似乎只是另一个有趣的 SharePoint Web 服务。如果您尝试获取文件的完整 url,则可以从 EncodedAbsUrl 和 FileRef 字段构建它。
http://slucy.wordpress.com/2009/06 /02/retrieve-pageurl-in-spsitedataquery/
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/