Retrieve data from any SharePoint list
Apply operations to lists
|
Merge multiple lists
Retrieve sites data, roles and permissions
Report Credentials
|
Retrieve data from any SharePoint list
Retrieving data from a SharePoint list
You can retrieve data from any SharePoint list using Enesys RS Data Extension specific query syntax which is based on XML.
In its simplest form, a query string is written as follows:
The list statement makes it possible to obtain data from a SharePoint list.
The attributes and the child elements make it possible to specify the desired list, as well as any selection criteria.
The previous query retrieves all items from the SharePoint list “Products” located on the site “/sites/demo/”.
Granted that you have created a data source of type "Enesys SharePoint Data Extension 2008", this is all there needs to be to run the query within the report designer and retrieve the list items:
All columns are returned because the fields element does not specify any column.
All items are returned because no condition is specified in the query element.
Specifying SharePoint list
A SharePoint list title can easily be modified by a user. To avoid this situation you may specify the SharePoint list to retrieve items from, by specifying its ID using the listID attribute rather that specifying its title using title attribute. The SharePoint list ID will not change over time.
However, the downside of using a list ID is that you won't be able to use the same report for some other site or for the same site.
Note that if you are using both attributes, listID will take the precedence over title . Even if you rely on list id to specify a SharePoint list, we encourage you to set title attribute as a meaningful reminder of list content.
Specifying list columns
You can specify the columns you would like to retrieve using the fields element as shown in the following screen shot:
Each column must be separated by a comma.
Instead of specifying each column,you can use a ‘*’ for retrieving all non hidden fields from the specified SharePoint list.
Leaving fields element empty will return all columns from the SharePoint list, including hidden ones. This is not recommended in most cases because of the performance impact.
Filtering list data
A filter can be applied to a list using Collaboration Application Markup Language query syntax. It doesn't take a long time to understand the basic principles. The CAML Query must be placed within the query element. The following query example will retrieve items where the Category column is equal to "Condiments":
You can also apply a filter at the report level using reporting services features. However, in that case, the whole list data is retrieved before the filter is applied. CAML filter is applied at SharePoint server side and it will improve the performance considerably if you just need a subset of the list. You can also use a mix of those filtering options when necessary.
Using column display names or internal names
SharePoint list columns have an internal name and a display name. When a column is initially created, the display name and the internal name of the column are the same (except if the name contains space or accent marks). When you modify the name of a column, it will only modify the display name. The internal name is never modified and you may end up with columns whose internal names no longer have any connections to the display names.
Though using internal names has the advantage of not breaking your report when a column name is changed, you can choose to use display names when specifying columns to retrieve by setting the useDisplayName attribute to true.
Using report parameters
Reporting Services lets you define parameters at the report level so that the user may be proposed several options for running the report.
Parameters may be used in various ways in the context of Enesys RS Data Extension queries (attributes, query,…). A parameter is composed of a name surrounded by the characters @ and ! (e.g. @product!).
When you specify a parameter in a query and the parameter is not already defined at the report level, it will be automatically created when you select the Layout view.
The following example shows how to return the data from the SharePoint "Products" list whose category is equal to the value of the "cat" parameter. The parameter will be replaced by the corresponding value when the report is executed.

As previously indicated, entering the parameter in the query string will automatically create the corresponding report parameter (unless it was already defined), as shown in the following image:

Note that you can provide the parameter’s values by using another dataset that will return values from a SharePoint list. A common usage is to create a dataset that returns distinct values from the column filtered by the parameter so that the user running the report can select a value amongst the existing values.
Note that you can use any other data source (e.g. SQL) for specifying parameter’s available values.
Multi-value parameters are supported. However their use makes only sense in the following constructs:
- sqlQuery statement with an IN clause:

- Caml Query In operator:

Expanding recurring events
The expandRecurrent attribute let's you expand recurring events for an event list.
Besides building reports displaying recurring events, a possible scenario is to export recurring events as an xml file using Reporting Services subscription features in order to feed another data source or a business process.

The expandRecurrent attribute goes along with expandFirstDate and expandLastDate required attributes that lets you define the range of dates for which recurring events will be expanded. Parameters may be used to set expandFirstDate and expandLastDate values.
The expandRecurrent attribute possible values are:
- “Automatic”: retrieves both recurring and non-recurring events for the date range specified by the expandFirstDate and expandLastDate attributes
- “Standard”: retrieves all events according to the CAML query and expands the recurring events for the date range specified by the expandFirstDate and expandLastDate attributes.
- “None”: retrieves events without expanding recurring events
In order to obtain events between two dates including the recurring events, you would write the following query, using the “Automatic” mode:

The “Automatic” mode is the easiest way to retrieve events (both recurring and non-recurring events) for a given date range. Unless you have a very specific scenario, you will mostly use this mode when retrieving events from an event list.
Using the “Standard” mode, you can imitate the “Automatic” mode by doing a query similar to this one:

Note:
All the events overlapping the specified date range are taken into account. If you only want to discard the overlapping events, you must add a sqlQuery statement like shown in the following picture.

Stripping Html tags
It is a well known limitation that Reporting Services is not able to handle html tags within a specific field. Thus, html data within a field will be displayed as plain text as shown in the following image:
Though, you may use your own approach to remove html tags by using Reporting Services embedded code features, we have added the ability to strip html tags for a specific SharePoint list using the stripHtml attribute:

The stripHtml attribute is optional and defaults to false if it's not defined.
Though not really appealing, stripping html makes text at least readable:

Using Running Values
Though Reporting Services makes it possible to calculate running values on the fly, it will not let you use aggregate functions on running values (max, min, etc).
To overcome this limitation and being able to meet specific scenarios, Enesys RS Data Extension lets you specify columns for handling running values. In that case, the running value being seen as a column on Reporting Services side, it is possible to apply aggregation function on it.
Columns containing running values are added using a customFields child element of the list element as shown in the following example:

Each field child element of customFields element represents a specific column holding a running value. The attributes let’s you specify the name of the new column that will be holding the running value, the data type of the column, the type of running value, the grouping column and the column holding the value.
To make it simple, the previous query will retrieve the Product and Quantity columns from the “Order Details” SharePoint list, ordered by “Product”. Enesys RS Data Extension will add a custom column named “RunningTotal” (name) of type Integer (dataType) and will calculate a running sum (op) based on the “Quantity” column (param). Each time the “Product” column value changes (groupColumnName), the running sum is reset to 0.
The following image shows what you will obtain when running the previous query within the Data view.
Note that the Running Sum is reset when the product value changes from "Aniseed Syrup" to "Boston Crab Meat".
It is important to note also that Enesys RS Data Extension will not automatically order the data on the groupColumnName column ("Product" in that case). It's up to you to order accordingly the SharePoint list using an OrderBy element within the CAML query. The groupColumnName attribute will only direct ERSDE to reset the running value when the groupColumnName's column value changes.

Retrieving items and folders in a specific folder
The default behaviour when retrieving items using a list element is to return all items within all folders and subfolders.
The optional folder attribute lets you retrieve items and folders in a specific SharePoint list folder as shown in the following query:

When specifying a folder attribute, you will retrieve items located in the specified folder as well as subfolder as shown in the following screenshot:

To retrieve root items and folders, set the folder attribute to a “/” (slash) value.
Instead of specifying the folder using a literal value, you may use a report parameter (e.g.: folder="@someReportParameter!").
Retrieving the first n items of a list
The rowLimit attribute let’s you specify the number of items to retrieve.
The following query will retrieve only the first five less expensive products:

Custom separator for multiple values
The following type of SharePoint columns may have multiple values:
- Choice
- Lookup
- Person or Group
- Attachments
By default, multiple values will be separated by a comma. You may specify your own separator by setting the multiValuesSeparator attribute value like shown in the following query:

Running this query, you will get each student skill and spoken language separated by two slashes as shown in the following screen shot captured from the report designer:

Expanding multiple Values
Retrieving multiple values separated by some separator will not help if you would like to group items based on the possible values of such a column.
To address this scenario, it is possible to duplicate items for each value stored in the desired multiple values column. The desired multiple values column is specified using the expandMultiValuesColumn attribute as shown in the following query:

By running this query, the “Skills” column which is of type choice and holds multiple values will only get one value for each student. On the other hand, students are duplicated accordingly to reflect each skill they have as shown in the following screenshot:

Without using expandMultiValuesColumn attribute, you would retrieve items in the following form:

Rather than specifying the column to expand as a literal, you may use a report parameter (e.g.: expandMultiValuesColumn="@ChoosenColumn!")
Important notice:
Be aware that items, being duplicated (somewhat like a join operation), some calculations may not be appropriate when building reports using this approach.
Retrieving attachments
Starting from version 2.1, the urls to the files that have been attached to a specific list item are available through the “Attachments” column. Prior to the version 2.1, the “Attachments” column was only returning the number of attachments.
Multiple attachments will be separated using the separator specified by multiValuesSeparator attribute or a comma if the attribute is not specified.
When you would like to display individual attachments in a report and possibly allow the user to click on the attachment for displaying the associate file, you may set the expandMultiValuesColumn attribute value to “Attachments” as shown in the following screenshot:

Items with several attachments will be duplicated thus allowing you to group items and display each attachment.
The following report layout uses this approach:

The important things to note are:
- A level one group is used to display item details. The item’s ID is used as the grouping expression:

- The table detail group is used to display attachments
- It has been made possible to open the attachment when displaying the report by specifying a jump to URL Navigation expression as shown in the following screenshot:

Retrieving user information
It is possible to retrieve information about users in a site collection by specifying “UserInfo” as the value of the title attribute of a list query element as shown in the following screenshot:

One interesting use of the “UserInfo” list is to join it to some other list in order to get more details about users specified using a “Person or Group” column.
The query shown in the following screenshot will join an Issue list and the "UserInfo" list based on the user assigned to the issue:

Retrieving item versions
Starting from Enesys RS Data Extensions version 2.1, it is possible to retrieve item versions using the itemVersions attribute.
For retrieving all versions, set itemVersions attribute value to “0”. For retrieving a specified number of item versions, set itemVersions attribute value to the number of versions you would like.
The following query shows how to retrieve all versions of items from SharePoint “Issues” list:

Important notice:
For obvious reasons, Enesys RS Data Extension relies on SharePoint Web Services rather than SharePoint object model for retrieving data. Due to SharePoint Web Services limitations, retrieving item versions is a very time consuming process. In order to improve performance, it is recommended to specify explicitly the SharePoint fields that need to be retrieved rather than keeping the field child element empty, thus retrieving all fields (even hidden ones).
Specifying a Caml query within the query child element for filtering items, when possible, will also help to improve performance when retrieving item versions.
Depending on your specific needs, an interesting option may be to jump to another report from a specific item in order to display item versions.
Retrieving meeting instances
When retrieving items from lists within a meeting workspace, you may specify the meeting instance for which you would like to retrieve items.
To retrieve items for all meeting occurrences, you can set the meetingInstanceId attribute value to “-1” as shown in the following query:

Apply operations to lists
Overview
You are not limited to build reports based on one SharePoint list. Enesys RS Data Extension lets you apply specific operations between two or more SharePoint lists.
You can define as many list statements as necessary and apply as many operations (sqlQuery statements) as you like in order to obtain the desired Dataset from which you will build your report.
Each list statement defined within a query returns a set of data items from a SharePoint list for which we will use the generic term "result set". The tableName attribute is used to give a unique name to this set of data. The unique name of the result set will serve as the basis for specifying result sets involved in operations.

You can manipulate "result sets" by using sqlQuery statements. The data resulting from a sqlQuery statement is considered a "result set" that can be further manipulated using other sqlQuery statements.
The following query shows three list statements used to retrieve data from three specific SharePoint lists as well as a sqlQuery statement used to further manipulate (join and group) the data retrieved from SharePoint lists.
The result of the sqlQuery statement will serve as the dataset needed by Reporting Services.
Joining result sets
The SQL INNER JOIN operation lets you join matching items between two result sets based on their joining columns. The tableName attribute lets you give a unique name to the set of data resulting from the inner join operation. It is possible to use this data for further operations.
The following image displays an INNER JOIN statement between the Products and the Suppliers SharePoint lists (bearing that a list element has been defined for each of them). Products that do not have a matching supplier won’t belong to the result set.

You can also use a SQL LEFT OUTER JOIN operation as shown below:

Joining lists is useful (though not limited to that usage) when dealing with SharePoint lists linked with a lookup field. For example you might want to display products grouped by suppliers and display the supplier company as well.
Please not that starting from version 2.1, a SharePoint lookup column will return 2 columns in the resulting Reporting Services dataset for holding both the actual value and the target list item’s ID. It is recommended to join lists using those ID rather than the actual value.
The sample query shown in the following Screenshot joins both SharePoint “Products” and “Suppliers” lists using Supplier lookup column. Rather than using the supplier value pointed to by the lookup column, the query relies on the supplier ID.

You will notice that the “SupplierID” column has not been specified in the fields element of the “Products” list. It has been automatically created by Enesys RS Data Extension for holding the ID of the “Supplier” pointed to by the lookup column.
Merging result sets
You can merge two result sets by using a SQL UNION operation. Both result sets must have matching fields and data types. However, two SharePoint lists can be merged even if they are not exactly identical as long as you only use shared fields in your list query statement that are used as part of the UNION statement as shown in the following image:

Getting distinct values
The SQL DISTINCT keyword lets you select unique items from a specific result set.

The DISTINCT keyword is especially useful for creating a report’s dataset used to set the available values of a report’s parameter. Say you have a SharePoint Products list with a Category column and you would like to let the user of your report select at run time the category of products that will be displayed in the report. You can easily achieve this by creating a specific report dataset as shown in the following image:

Filtering a result set
The SQL WHERE clause lets you select a subset of the result set specified in the FROM clause based on the filtering expression given in the WHERE clause.

Though it is possible to filter SharePoint lists using CAML query, selecting a subset of a result set may be interesting in some complex queries involving several operations.
Report parameters may be used within the where clause as shown in the following example:

Merge multiple lists
Overview
Enesys RS Data Extension provides the multiList query statement for merging a variable number of lists using one operation.
Two approaches are available:
- The first one is based on a SharePoint list that enumerates all the lists you want to merge.
- The second approach lets you merge all lists sharing a common title within a site collection.
You specify the desired approach by setting the type attribute to “MergingList” or “RollUpList”.
Merging lists using a reference list
Use the multiList element with the type attribute set to “MergingList” for merging a set of SharePoint lists that are enumerated in a specific SharePoint list. The term "merging list" will be used to refer to this list.
You specify the merging list that is to be used by setting its title and relativeSiteUrl attributes.
The merging list is a SharePoint list with four mandatory columns. Each item of this list will provide information about a SharePoint list that is to be merged.

The SharePoint lists that need to be merged are not necessarily completely identical as you can specify the columns that will be merged using the fields element. Moreover, you can specify a filter that will be applied to each list before being merged:

A specific column named " rstLabel" is added to the result set obtained from the multiList query element. This column will be filled with the value of the merging list's column information depending on the list from which the item is retrieved:

Rolling up lists in a site collection
Use the multiList element with the type attribute set to “RollUpList” for merging lists having the same “title” within an entire site collection.
The following query will merge all SharePoint lists named “Contacts 01” within the entire “/sites/demo/” site collection:

You are not obliged to merge lists starting from the root of the site collection. It is possible to specify a child site as the starting point of the merging process (e.g.: relativeSiteUrl=”/sites/demo/demosubsite01/”).
When running such a query, a column named “rstLabel” will be added to the result set. This column will contain the relative site Url of the list from which the items have been retrieved as shown in the following screenshot where the previous query is run from the report designer:

Rather than specifying the starting site in the query, you may use a report parameter (e.g.: relativeSiteUrl=”@StartingSiteUrl!”).
Retrieve sites data, roles and permissions
List collection
The listCollection query element lets you retrieve information about all the lists in a site or a set of sites.

Optionally, you can retrieve the permissions as well for each list by setting the includePermissions attribute to true.
List permissions
The listPermissions query element lets you retrieve permissions from a specific list.

Parameters may be used for the listID and relativeSiteUrl attributes values.
Web permissions
The webPermissions query element lets you retrieve the permissions given at the site level for a specific site or a set of sites.
Optionally, you can also retrieve the users (or AD Groups) belonging to each group by setting the expandGroups attribute to true.
Retrieving SharePoint groups
The webGroups query element lets you retrieve SharePoint groups from a site collection.

Optionally, you can also retrieve the users (or AD Groups) within each group by setting the expandGroups attribute to true.
Specifying a set of sites
Except listPermissions, all those commands are sharing a common approch for specifying sites for which they apply.
You can specify the sites for which the commands apply in one of these three ways:
- By writing directly the relative url of the site (eg: /sites/demo/) within the query

- By using a report parameter so that the user might select the site when running the report.

- By specifying a SharePoint list that contains the list of sites to handle.

Ready-to-use reports
We have included several sample reports that lets you display list, groups and permissions for your SharePoint sites. The provided reports can be used as is or as a starting point for creating your own reports.
You can use the reports as the basis for permissions and groups analysis and have an overall vision of the permissions set for the lists of a site. You can also use the reports as an interactive tool as we have implemented Reporting Services Navigation features that lets you jump directly from the report to SharePoint Site and List Settings pages or to other reports for details refinements.
The IT - List Collection from sites in a reference list report will display information about lists for the set of sites defined in the list named "Site collection" (the SharePoint list named "Site Collection" contains an item for each site) . While viewing the report, you can click on the name of a list to launch a report that will display permissions details for the list. You can click on "Display Group details" to launch a new report that will display permissions (roles) for the specific site.:
List Collection Report - Click for larger image
The " IT - Lists permissions " and " IT - Lists and permissions for a specific site " reports lets you display in one report both lists collection and permissions for each list. While viewing the report, you can click on the list title to open the SharePoint Customize page fo the list (see the image). You can click on " Display Group details " to launch a new report that will display permissions (roles) for the specific site. Permissions are not displayed by default, you must click on the plus sign (+) to display the permissions associated with the lists of a specific type:
Lists and Permissions report - click for larger image
The " IT - SharePoint Groups and Users for a site " report lets you display site groups and users for a specific site. While viewing the report, you can click on the " Manage Site Groups " link to open the SharePoint "Manage Site Groups" page for the selected site (see the image below).
Web Permissions report - click for larger image
Report Credentials
Setting report credentials
All credential options available with Reporting Services have been implemented unless it would not make sense in the context of Enesys RS Data Extension .
You can run the report using an account for which credentials are stored securely on the Report server:

You can run the report under the credentials of the current user running the report :

You can ask for the user to enter its credentials when running the report :
