4

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

2

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

1

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' />";
  • Still the values will be empty unless you include LookupMulti field in where clause. – Nadeem Yousuf Aug 20 '13 at 9:07
  • ok, I did not know that. I have not worked with SPSiteDataQuery. – Amit Bhagat Aug 20 '13 at 13:05
  • Can SPQuery be used inside SPSiteDataQuery to iterate through all the lists manually? If yes can anyone post an example? – SharePointer Aug 21 '13 at 6:26
  • As I mentioned, I have not used SPSiteDataQuery. Please ask someone else. – Amit Bhagat Aug 21 '13 at 7:40
0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.