简体   繁体   中英

How to filter SharePoint List using CAML query?

I am doing SSRS to retrieve data from two SharePoint lists. One is the viewing part and the other is for the filtering part. This is easily done on a SQLServer database Data Source, but how can it be achieved using SharePoint lists?

The following is my query: The @name is a report parameter retrieved from the other list.

    <Query>
<Method Namespace="http://schemas.microsoft.com/sharepoint/soap/" Name="GetListItems">
        <Parameters>
            <Parameter Name="listName">
                <DefaultValue>{D5D33A07-D1CA-440F-8A6B-912B9CE5BB2F}</DefaultValue>
            </Parameter>
            <Parameter Name="rowLimit">
                <DefaultValue>9999</DefaultValue>
            </Parameter>
            <Parameter Name="viewName">
                <DefaultValue>{F5459664-7C2F-4618-81FC-F2275FB2FBCF}</DefaultValue>
            </Parameter>
        </Parameters>
</Method>
<Where>
     <Eq>
         <FieldRef Name='ows_Firstname' />
         <Value Type='Text'>@name</Value>
     </Eq>
</Where>
    <ElementPath IgnoreNamespaces="true">GetListItemsResponse/GetListItemsResult/listitems/data/row{@ows_EmployeeID,@ows_Firstname,@ows_Lastname,@ows_Department}</ElementPath> 
<SoapAction>http://schemas.microsoft.com/sharepoint/soap/GetListItems</SoapAction>
</Query>

Please help.

Jane, you have two options:

  1. SQL Server 2008 R2 comes with the Sharepoint List Connection type (see link for tutorial) where the connection is as easy as using an SQL data source.

  2. If you are unfortunate and don't have access to that connection type you can make use of Sharepoint Web Services (specifically the lists.asmx service) for your XML query. See this tutorial: SQL Reporting Services data from SharePoint lists .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM