Thursday, March 02, 2006

 

Update: Reporting over Sharepoint lists from MS Reporting Services

About 6 months ago, I published an article about writing a reporting services data extension to query lists in Sharepoint sites. The article focussed mainly on "how to extend MS Reporting Services", but from the many responses I received, I reckon that many people are building production solutions around the sample presented in that article. As a matter of fact: I did so myself. I created a number of reports for the team sites we use in our projects at Macaw. Every now and then, I had the need for extra functionality in the extension itself.

I decided to publish this enhanced version to the public. A few warnings in advance: this is free software, it comes with source code, but I do not take any responsibility for the quality of the software oor for any damage caused by the use of it. This is still a sample and may not be fit for production environments.

First of all: the code and binaries of the Macaw.ReportingServices.SharepointListExtension can be downloaded here. Installation and configuration procedures are exactly identical to the former version of the extension.

Now on to the new functionality. All of the new features can be configured throught the query string box of the (the box that you would normally use to enter the SQL query of your report)..


Reporting on views

In the old version, the query string of the dataset could only specify a list name. Filtering and sorting would be specified by the default view of that list. In the new version, you can use the query string to specify an existing view for the list. The sorting and filtering of this view will be reflected in the dataset in the report. Specifying a view for your query is easy as this: Note that the different settings are separated by semicolons as you would normally see in a database connection string. In the previous version, the list would be identified by entering the list name as the query string (without the list= part). You can still do this for backward compatibility, but the "right" format is now list=ListName.
If you specify no view at all, instead of getting the default view, you will now get the full table: all fields and all rows.

Stripping HTML from multiline fields

Many people use multi line texts in their lists. Even if you do not allow the addition of links and markup (bold/italic), SharePoint stores the content of these fields as HTML. It will contain <div> tags. In a normal Reporting Services report, these tags will show up visibly. With the new striphtml parameter, you can have the extension remove any HTML markup from the multi-line fields before returning the data for rendering the report.

Charting changes in Issue lists over time

In Sharepoint, when you base your list on the Issues templates, the list will keep track of historic data. This allows you to see which changes have occurred to the list item and when (and by whom). When you want to create a report on the current state of the list, that's fine, but sometimes it is interesting to get insights in the history of the list, answering questions like "How did the number of active issues with severity high change over time?". To do this, I created a new parameter that you can set: When you do this, the resulting dataset get an extra field (GridDate). For each day, the dataset is filled with copies of all items that existed at that date (with the values they had on that date). This means that the dataset can grow very large if the changes span a long period. But it also allows you to create charts like this:


Just create an Area chart, use = Count(Fields!ID.Value) as the expression for the value, while using = Fields!GridDate.Value as the category group and = Fields!Status.Value or whatever you want to use to chart as the Series group. Valid values for the grid parameter are Daily, Weekly, Monthly and None.

The siteUrl parameter

You still specify the Url of the WSS site containing your data in the connection string of your datasource. However, if you want to use the same report for many sites (with identical lists and views), you may want to specify the site Url as a parameter. This also allows you to make a web part that shows a specific report querying the current site. The parameter will automatically show up when you use the data extension in your report. When you leave the parameter blank, the value from the datasource connection string will be used.

Labels:


Comments:
I get an error when I try to use this with SQL Server Reporting Services 2005 - have you tested this with 2005 or just 2000?

I get Metadata file ... MicrosoftReportingServices.Interface.dll could not be opened -- Version 2.0 is not a compatible version. Any ideas?
 
I've been trying to set this up, after I enter the site =[url] then entery the query string "list=[listname]" I get an error "There is an error in the query. Object reference not set to an instance of an object." I can browse the list if I open the url in IE. Any thoughts?
 
@James: I have not yet been able to test with SSRS2005, so it may indeed not work with that version. I may look into this in the future, but will leave for vacation for 4 weeks next week, so don't wait for it.

@anonymous: That's not a pretty error message. Sorry 'bout that. Try specifying a view name as well?
 
Is it possible to base a report on multiple lists?

list=Task; view=All Tasks;
list=Resource; view=All Resources;

Then have a report that gets all data from both views?

I hope so...
 
@Russell: Yes, that is certainly possible, but not in the way you propose. Here is what you do: create one report, using multiple datasets (these datasets can share one common datasource). Each dataset can specify it's own list and view. In your report, you can add multiple charts and tables, each using their own dataset.

What is (sadly) not possible in Sharepoint is to join to lists together to one view. There are certainly situations where this would be desirable, but I cannot help you there.
 
I was able to sucessfully convert the project to VB.Net - a couple of methods are set to read/write but should be write only. I had to create a secondary method to allow read access to the password/id.

I fixed the problem with domain accounts not working by changing the GetCredential to have this code:

If (conn.IntegratedSecurity) Then
Return CredentialCache.DefaultCredentials
Else
Dim sUser As String = ""
Dim sDomain As String = ""
sUser = conn.GetUserName
If sUser.Contains("\") Then
sDomain = sUser.Split("\")(0)
sUser = sUser.Split("\")(1)
Return New NetworkCredential(sUser, conn.GetPassword, sDomain)
Else
Return New NetworkCredential(sUser, conn.GetPassword)
End If
End If
 
Thats a shame, because it seems when exporting a SSRS report to excel, sub-reports are not displayed correctly. I had hoped to get around this problem by linking by data in the query instead.
 
I'm only getting the first 100 rows from my Sharepoint List. Any idea what I need to do to the webservice call to get the rest of the data?
 
If you really wanted to report off of multiple Sharepoint Lists then you could start with Teun's code and tweak it and rename it so that it returned exactly and only the data that you wanted. That is - change it to get the two or three sharepoint Lists that you are after, turn them into datasets, join them, and then put that together into one dataset and return the conglomeration to SSRS to report off of.

I don't like that solution however as it is specific to a single report and highly fragile. It would however solve you problem.
 
Great example. Finally got it working..only one problem I need to report on multiple DLs not just one. I would like to merge the datasets from each. Though reporting services could do this but it doesn't seem to. Was thinking about extending the code to allow multiple query params each representing a similiar SP web service. Any thoughts?
 
Teun, any luck connection the sharepoint lists with SQL Server Reporting Services 2005?
 
Hi! Helpful article!
Its work wonderful in Visual Studio .Net
But after deploying on the report server and looking reports from the report manager
i get this error:

Reporting Services Error
An error has occurred during report processing. (rsProcessingAborted)
Cannot create a data reader for data set 'RequestDate'. (rsErrorCreatingDataReader)

How to solve this problem?
 
Teun, thanks for this solution, it realy helps a lot!

But when I use the striphtml=true flag, it seems to add a space character before each line in the multiple-line field. The first line is the only one which is fine.

Thanks for any idea on how to handle this!
 
I need to create complex queries on XML stored in form documents (created by Infopath) stored in a SharePoint form library in order to generate different sorts of statistics and reports from these.

Is it possible to query the content of the XML documents in a form library, and not just the list column data (not all data may be displayed as columns in a view)?
 
No, I don't think you can do that. You can report over the metadata of documents in alibrary, but not on the contents (which could be anything, as far as WSS is concerned). You could look into wiring events to your document library that extract relevant information from the document when it is saved and store it in properties that can be reported on (wiring events in WSS is not easy though and not my thing either).
 
Hi,
We have developed a data extension for reporting services that makes it possible to pass reporting services parameteters, combine lists using Sql-like operators and some other features.
I have to admit that the initial idea came from your article. We had a real need for reporting over sharepoint data.
Though your exention is fine we needed much more features and this turned into a project by itself. We decided to make it a commercial software.
An evaluation version is available on our web site (http://www.enesyssoftware.com).
I you consider this comment has nothing to on your blog, please don't hesitate to delete it.
Regards,
 
That's very nice! Of course, I cannot give any support on the open source sample of this article. So, for many people, your solution will be a great fit. Good luck!
 
Anonymous asked why he/she was only getting 100 record results --
to fix: change command.cs
line "XmlNode ItemsNode = lists.GetListItems(TechListName, TechViewName, query, fields, "", null);" to "XmlNode ItemsNode = lists.GetListItems(TechListName, TechViewName, query, fields, "1000000", null);" -- sets rowcount. Also for SQL server 2005, no report designer folder -- instead C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies

Great solution Teun!
 
Thanks, anonymous. Actually, most users will be more comfortable with setting the page size of their view very high then hardcoding it into the extension and recompile.
Of course, if you use the same view for on-screen viewing as well, you may want to create a special view only for reporting purposes that has a very high page limit.
 
Has anyone tried this solution with WSS 3.0 and if you did will you share some info on how you got it to work?
The server I am using: windows 2003, SQL 2005, WSS 3.0, .net framework 3.0.
 
thx teun for the great solution and writeup.
i had the same problem as a poster above:
Reporting Services Error
An error has occurred during report processing. (rsProcessingAborted)
Cannot create a data reader for data set 'RequestDate'. (rsErrorCreatingDataReader)

then i followed the instructions on modifying rssrvpolicy.config and it's working!
 
I posted a comment early on about reporting of WSS 3.0. I am having a hard time getting this to work. Can anyone please shed some light on this??
I keep getting this error message for the query: "There is an error in the query. Object reference not set to an instance of an object."
 
haven't tried it with WSS 3.0, but just an fyi, that error about the query may be caused by some other problem, such as the "connection string" or the credentials.
 
i'm trying to get this to work in my reporting services 2005/visual studio 2005 environment.
i modified the rsreportserver.config and rssrvpolicy.config in the folder C:\Program Files\Microsoft SQL Server\MSSQL.3\Reporting Services\ReportServer. i loaded an existing report and after tweaking the datasource a bit, it ran fine.
however, i can't get visual studio 2005 to recognize the SPSLIST data extension. anyone figured this out?
 
dhoang, what is it that you modified in the rsreportserver.config file?
 
Hi,

Great Solution! But I'm getting the same error: "There is an error in the query. Object reference not set to an instance of an object."
Can not get what I'm doing wrong. I've followed all instructions. Any help is much appreciated. Thanks, Zam
 
First of all --- thank you very much for sharing your solution. It really helps me a lot in my daily work.
I only have one question: sometimes I have columns in my Sharepoint library which consists of more than 255 characters.
Unfortunately I only get 255 characters in my reports. Is there a way that I can show more than 255 characters on my sharepoint column in my report.
Thank you very much for your help

Regards, Karsten
 
I downloaded Macaw.ReportingServices.SharepointListExtension.sql2005.zip. When I try to open Macaw.ReportingServices.SharepointListExtension.sln, it gave me error
"The application for project 'C:\MyFiles\SPDataExtension\Macaw.ReportingServices.SharepointlistExtension.csproj' is not installed" I check that directory, the file is there. Any ideas? Thanks...
 
@anonymous: This looks as if you have no Visual Studio 2005 installed. If you just want to use the extension ands are not interested in the code, you can use the .dll files that are included in the download. Otherwise, install VS2005.
 
Teun,

You are an absolute star for sharing your work. I have started from your code and been able to do exactly what I wanted.

Wonderful stuff.

Many thanks!!!
Etienne
 
Can we generate reports of sharepoint list using some out of box feature of sharepoint? i am really working hard on this and didnt get any solution.
Can anyone help me out?
 
Post a Comment

Links to this post:

Create a Link



<< Home

This page is powered by Blogger. Isn't yours?