Dynamically Building Query XML to hit SharePoint List
Ok, so I'm in a real bind, I've fought with this in 2005 and now I've upgraded my report to SSRS 2008 R2, and I still can't get it to work. The scenario is this. I have a report that's hitting a Sharepoint list. Now in the Report Parameters, I have several parameters including DateRange (two separate dates (Begin and End)), an open text box (for title), and a drop down full of values in the picklist for one of the sharepoint fields. Now, normally this would be pretty simple to just pass them into the dataset. I've added the parameters as dataset parameters, but my question is this. The Parameters work like this. If I want to search for just items that have "Road work" in the title, I type roadwork into the empty box. But if I want all items with "Road Work" in the title for this year, I would put "Road Work" in the box, and select dates 1/1/2011 and 12/31/2011. So basically as a result of this I need to basically dynamically build the Query XML that is going to run. If this where SQL for example I would build a varchar variable to have my where clause based on what gets passed and then add it to my varchar variable containing my select and from clauses, and then say EXEC (@SQL) I've been searching for a way to do this with an XML query of a sharepoint list and have been coming up empty. Any help? Here is the XML I have so far. <RSSharePointList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <ListName>Tracking Sheets</ListName> <ViewFields> *Fields I'm viewing </ViewFields> <Query> <Where> <And> <Contains> <FieldRef Name="Title"/> <Value Type="Text"> <Parameter Name="SearchAssignment"/> </Value> </Contains> <Contains> <FieldRef Name="Coordinator"/> <Value Type="Text"> <Parameter Name="Coordinator"/> </Value> </Contains> </And> </Where> </Query> </RSSharePointList>
January 27th, 2011 3:11pm

Hi KmackGFNet, Please modify you XML query to below, I think you could achieve your requirement: <RSSharePointList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <ListName>Tracking Sheets</ListName> <ViewFields> *Fields I'm viewing </ViewFields> <Query> <Where> <Contains> <FieldRef Name="Title"/> <Value Type="Text"> <Parameter Name="SearchAssignment"/> </Value> </Contains> </Where> <Where> <Contains> <FieldRef Name="Coordinator"/> <Value Type="Text"> <Parameter Name="Coordinator"/> </Value> </Contains> </Where> </Query> </RSSharePointList> For more information, please see: http://nikspatel.wordpress.com/2010/06/11/step-by-step-consuming-sharepoint-2010-lists-data-in-the-ssrs-2008-r2-reports/ Thanks, Challen FuChallen Fu [MSFT] MSDN Community Support | Feedback to us Get or Request Code Sample from Microsoft Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Free Windows Admin Tool Kit Click here and download it now
January 31st, 2011 12:58am

Ok I found a solution, and its using the XAML you pointed out above. The secret was to build a code function into the report that based on the parameters built the xml needed. Then in your data source, call the function.
February 4th, 2011 7:48am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics