Question

I have a requirement to iterate through multiple task lists under SharePoint sites and sub-sites. I am using SPSiteDataQuery to achieve this. I have an issue with fetching the data when the column is of type look-up. I am using following code:

query.ViewFields += "<FieldRef Name=\"Predecessors\" Type=\"Lookup\" Nullable=\"TRUE\" />";

This fetches all the other columns in the datatable, but the value of column Predecessors is always blank for all the rows.

Any pointers in this regard would be very helpful.

Cheers Chitranshi | SharePoint Consultant| Mindfire Solutions

Was it helpful?

Solution 3

SPSiteDataQuery does not support multiple value look up columns. However, one can filter the results using SPsiteDataQuery on look up column.

In order to get the values of look up column use SPQuery to iterate through each and every lists which you can get through the SPSiteDataQuery.

In my approach I got the list ids of various lists in my sites and sub-sites using SPSiteDataQuery and using those list ids I fetched the list and the corresponding values for the look-up column using SPQuery.

Cheers Chitranshi | SharePoint Consultant| Mindfire Solutions

OTHER TIPS

This is a known issue. SPSiteDataQuery returns no data when ViewFields property includes a multi-value field.If filtering on multi-value field is what is needed, then include the multi-value field in the <Where/> clause of the query.

Refer this: http://support.microsoft.com/kb/2703054

I think you are querying Tasks lists which has 'Predecssors' field which actually allows multiple lookup values so you should use "LookupMulti" instead of "Lookup". I got this idea from this reference: http://support.microsoft.com/kb/2703054

query.ViewFields += "<FieldRef Name='Predecessors' Type='LookupMulti' Nullable='TRUE' />";
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top