SPSiteDataQuery and the Person or Group type
-
Tuesday, September 09, 2008 8:21 PM
I have an issue I can't resolve or find a reference to in any user group. I'm using SPSiteDataQuery to pull data from a number of task lists. The query will return the data so long as I don't include a column in my viewfields list of the "Person or Group" type where multiple selections are allowed. I can get data returned if the viewfields list contains a column of Person or Group type WITHOUT multiple selections allowed. I don't get an error; I simply get no data returned. If I comment out the "offending" column from my query, I get the data I expect. Here is the query:
SPSiteDataQuery query = new SPSiteDataQuery();
query.Lists = "<Lists ServerTemplate=\"107\" />";
query.ViewFields =
"<FieldRef Name='ID' />" +
"<FieldRef Name='UniqueId' />" +
"<FieldRef Name='ParentListID1' />" +
"<FieldRef Name='Priority' />" +
"<FieldRef Name='Status' />" +
"<FieldRef Name='PercentComplete' />" +
"<FieldRef Name='AssignedTo' />" +
"<FieldRef Name='Body' />" +
"<FieldRef Name='StartDate' />" +
"<FieldRef Name='DueDate' />" +
"<FieldRef Name='Status' />" +
"<FieldRef Name='TimeEstimate1' />" +
"<FieldRef Name='Author' />" +
"<FieldRef Name='Category12' />" +
"<FieldRef Name='Subcategory1' />" +
"<FieldRef Name='Originat1' />" +
"<FieldRef Name='_x0052_FI1' />" +
"<FieldRef Name='RFIID1' />" +
"<FieldRef Name='AssignDate1' />" +
"<FieldRef Name='AcceptDate1' />" +
"<FieldRef Name='CancelDate1' />" +
"<FieldRef Name='DeclineDate1' />" +
"<FieldRef Name='CompletionDate1' />" +
"<FieldRef Name='Title' />";
The offending column is AssignedTo, which is a site column. I tried referencing the column by ID instead of by name (e.g., "<FieldRef ID='" + root.Fields["Assigned To"].Id + "' />" following an earlier instantiation "SPWeb root = site.RootWeb;"), but it made no difference in the result.
Does anyone know what's wrong here and what I can do to fix the problem?
Answers
-
Tuesday, September 09, 2008 8:50 PM
I am not sure if this is the official Microsoft answer to your question, but this blog post mentions that the query doesn't work for lookups or person fields.
http://www.sharepointblogs.com/michael/archive/2007/06/28/implementing-spsitedataquery-learning-by-doing.aspx
It would be interesting to see what MSFT has to say for this.
Michael
Michael Van Cleave - MCT, MCPD, MCTS, MCSD .NET and SharePoint Consultant - Qortex LLC.- Marked As Answer by dragonmagnet Wednesday, September 10, 2008 2:57 PM
-
Wednesday, September 10, 2008 4:36 AM
I had same problem with Content Query Webpart. This wont return any results if view fields has lookupfield with multi-choice enabled.
The following Blog comment says "The Cross List Query [XLQ], which is the data source of the CQWP does not support choice or lookup fields that have multi-choice enabled"
Link: http://blogs.msdn.com/ecm/archive/2006/10/25/configuring-and-customizing-the-content-query-web-part.aspx
-Sridhar http://sridharu.blogspot.com- Marked As Answer by dragonmagnet Wednesday, September 10, 2008 2:57 PM
All Replies
-
Tuesday, September 09, 2008 8:45 PMI am not sure if this would help, but have you tried including the type in the field ref when you are setting the ViewFields.
Michael Van Cleave - MCT, MCPD, MCTS, MCSD .NET and SharePoint Consultant - Qortex LLC. -
Tuesday, September 09, 2008 8:50 PM
I am not sure if this is the official Microsoft answer to your question, but this blog post mentions that the query doesn't work for lookups or person fields.
http://www.sharepointblogs.com/michael/archive/2007/06/28/implementing-spsitedataquery-learning-by-doing.aspx
It would be interesting to see what MSFT has to say for this.
Michael
Michael Van Cleave - MCT, MCPD, MCTS, MCSD .NET and SharePoint Consultant - Qortex LLC.- Marked As Answer by dragonmagnet Wednesday, September 10, 2008 2:57 PM
-
Tuesday, September 09, 2008 9:30 PMI did some tests with the User or Group columns and it DOES work for those columns that do NOT permit multiple selections. We are building a system, however, that requires the ability to select more than one person to assign a task to. If I can't find a solution, it will have a real impact on our development schedule. Any and all thoughts on the matter are welcome.
-
Wednesday, September 10, 2008 4:36 AM
I had same problem with Content Query Webpart. This wont return any results if view fields has lookupfield with multi-choice enabled.
The following Blog comment says "The Cross List Query [XLQ], which is the data source of the CQWP does not support choice or lookup fields that have multi-choice enabled"
Link: http://blogs.msdn.com/ecm/archive/2006/10/25/configuring-and-customizing-the-content-query-web-part.aspx
-Sridhar http://sridharu.blogspot.com- Marked As Answer by dragonmagnet Wednesday, September 10, 2008 2:57 PM
-
Wednesday, September 10, 2008 2:59 PM
Okay, it looks like we'll need to take the less pleasant approach of looping through the lists one at a time. Thanks for the assist!
Dan

