R – why GetSiteData(query) returns wrong values

camlsharepoint

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);

Best Answer

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/

Related Topic